new EventBus() → {EventBus}
Create an EventBus. Only one EventBus instance will be created in an application.
EventBus is used as a global event bus for custom events.
Returns:
singleton
- Type
- EventBus
Methods
off(type, listeneropt)
Remove an event listener.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
string | The name of the event to remove. |
|
listener |
function |
<optional> |
The callback function for when this event is triggered. If no listener is provided, all listeners of the type will be removed. |
on(type, listener)
Add an event listener.
Parameters:
Name | Type | Description |
---|---|---|
type |
string | The name of the event to listen on. |
listener |
function | The callback function for when this event is triggered. |
trigger(type, dataopt)
Trigger a custom event.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
string | The name of the event to trigger. |
|
data |
object |
<optional> |
Arbitrary data to be triggered with this event. |