Events.on method
Events › on
Official
Add an event listener.Signature:
on(name: string, callback: (...data: unknown[]) => unknown, ctx?: unknown): EventRefParameters:
| Parameter | Type | Description |
|---|---|---|
| name | string | The name of the event. |
| callback | (...data: unknown[]) => unknown | The callback to call when the event is triggered. |
| ctx? | unknown | The context passed as this to the callback. |
Returns: EventRef — A reference to the event listener.
Since: 0.9.7
Example:
events.on('my-event', (arg1, arg2) => { console.log(arg1, arg2);});