Function
Static Public Summary | ||
public |
Generates a decorator function to convert a class into a custom element
through the |
|
public |
Generates a decorator function to includes many |
Static Public
public element(elementName: string): Function source
import element from 'minimap/lib/decorators/element.js'
Generates a decorator function to convert a class into a custom element
through the registerOrUpdateElement
method from atom-utils
.
The decorator will take care to return the generated element class so that you can just export it directly as demonstrated below.
As supported by the registerOrUpdateElement
method, static member will
be available on the new class.
Note: As there's some limitations when modifying the prototype
of a custom element, if you need to inject element callbacks (like
createdCallback
) through a mixin, the mixins should be included before
converting the class as a custom element. You'll be able to achieve that by
placing the include
decorator after the element
one as shown in the
second example.
Params:
Name | Type | Attribute | Description |
elementName | string | the node name of the element to register |
Example:
@element('dummy-element-name')
export default class SomeClass {
// ...
}
@element('dummy-element-with-mixin')
@include(SomeMixin)
export default class SomeClass {
// ...
}
public include(mixins: ...Mixin): function(cls: Function): Function source
import include from 'minimap/lib/decorators/include.js'
Generates a decorator function to includes many mixto
mixins into a class.
Params:
Name | Type | Attribute | Description |
mixins | ...Mixin | the mixins to include in the class |
Return:
function(cls: Function): Function | the decorator function that will include the specified mixins |
Example:
@include(SomeMixin)
export default class SomeClass {
// ...
}