EventSystem

EventSystem

Handles sending / recieving named events

Methods

(static) registerEventCallback(eventName, callback) → {object}

Description:
  • Register a callback to be called when the given event is triggered
Source:
Example
registerEventCallback("myEvent", ({detail: detail})=>{
    //My event has triggered
    console.log("MyEvent triggered with details:", detail);
});
Parameters:
Name Type Description
eventName string The name of the event to register
callback function The callback to call when the event triggers
Returns:
- An object with a method delete(), that removes the registered callback
Type
object

(static) triggerEvent(eventName, detailopt) → {boolean}

Description:
  • Trigger the event with the given name
Source:
Example
triggerEvent("myEvent", {
    someData: "MyEventData"
});
Parameters:
Name Type Attributes Default Description
eventName string The name of the event to trigger
detail * <optional>
null The event detail to supply to the CustomEvent
Returns:
- true/false depending on if any callback asked to prevent default
Type
boolean

(async, static) triggerEventAsync(eventName, detailopt) → {Promise.<boolean>}

Description:
  • Trigger the event with the given name
Source:
Example
triggerEvent("myEvent", {
    someData: "MyEventData"
});
Parameters:
Name Type Attributes Default Description
eventName string The name of the event to trigger
detail * <optional>
null The event detail to supply to the CustomEvent
Returns:
- true/false depending on if any callback asked to prevent default
Type
Promise.<boolean>