Version: 4.2.1
Component
A class used to manage events in a component
Properties#
VERSION#
Version info string
Type: string
Component.VERSION; // ex) 3.0.0
Methods#
trigger#
Trigger a custom event.
Returns: this
- An instance of the component itself
| PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
|---|---|---|---|---|
| event | string | ComponentEvent | no | The name of the custom event to be triggered or an instance of the ComponentEvent | |
| params | Array<any> | $ts:... | no | Event data to be sent when triggering a custom event |
once#
Executed event just one time.
Returns: this
- An instance of the component itself
| PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
|---|---|---|---|---|
| eventName | string | $ts:... | no | The name of the event to be attached or an event name - event handler mapped object. | |
| handlerToAttach | function | $ts:... | yes | The handler function of the event to be attached |
hasOn#
Checks whether an event has been attached to a component.
Returns: boolean
- Indicates whether the event is attached.
| PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
|---|---|---|---|---|
| eventName | string | no | The name of the event to be attached |
on#
Attaches an event to a component.
Returns: this
- An instance of a component itself
| PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
|---|---|---|---|---|
| eventName | string | $ts:... | no | The name of the event to be attached or an event name - event handler mapped object. | |
| handlerToAttach | function | $ts:... | yes | The handler function of the event to be attached |
off#
Detaches an event from the component.
If the eventName is not given this will detach all event handlers attached.
If the handlerToDetach is not given, this will detach all event handlers for eventName.
Returns: this
- An instance of a component itself
| PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
|---|---|---|---|---|
| eventName | string | $ts:... | yes | The name of the event to be detached | |
| handlerToDetach | function | $ts:... | yes | The handler function of the event to be detached |