SimpleEventBus
This class provides methods for managing the flow of the events. See the Global Client Events article for more information about the system out-of-the-box events that the class can interact with.
on(eventType, callback)
Use this method to subscribe to an event.
Parameter(s):
Name | Type | Mandatory | Default value |
---|---|---|---|
eventType | String | Y | N |
callback | Function | Y | N |
Return:
Type | Description |
---|---|
Object | An object containing a method to unsubscribe from the event. |
Example:
on()
const obj = SimpleEventBus.on('myEvent', (data) => { alert(data); })
obj.unsubscribe();
emit(eventType, data)
Use this method in client scripts or widgets to initiate an event.
Parameter(s):
Name | Type | Mandatory | Default value |
---|---|---|---|
eventType | String | Y | N |
data | Any | N | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
emit()
SimpleEventBus.emit('myEvent', 'text')
deleteEvent(eventType)
Use this method to delete an event.
Parameter(s):
Name | Type | Mandatory | Default value |
---|---|---|---|
eventType | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
deleteEvent()
const obj = SimpleEventBus.deleteEvent('myEvent')
reset()
Use this method to reset all events and subscriptions.
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
reset()
SimpleEventBus.reset()