PluginEventSourceImpl.on method
Add an event listener.
Signature:
on(name: EventName, callback: (...args: Args) => Promisable<void>, thisArg?: unknown): AsyncEventRefParameters:
| Parameter | Type | Description |
|---|---|---|
| name | EventName | The name of the event. |
| callback | (...args: Args) => Promisable<void> | The callback to call when the event is triggered. |
| thisArg? | unknown | The context passed as this to the callback. |
Returns: AsyncEventRef — A reference to the event listener.
Remarks:
Not refactored to parameter-object pattern, to keep the parity withobsidian#Events#on (or once, correspondingly).Example:
events.on('my-event', async (arg1, arg2) => { await sleep(100); console.log(arg1, arg2);});