Core
Framework v2.x
2

trigger #

Triggers a custom event.

This allows interactions with others plugins using hooks or pipes.

If the event is listened by pipes, the result of the pipe chain will be returned in a promise. If there is no listener, the result will be the same payload. This behavior can be used for a Remote Procedure Call (RPC) system between plugins.

Arguments #

Copied to clipboard!
trigger(eventName: string, ...any): Promise<any>;

Arguments Type Description
event
string
Custom event name
payload
object
Event payload

Note: the triggered event is renamed by the following format:
plugin-<plugin name>:<event>.

Returns #

Returns a promise resolving to the pipe chain result.

Usage #

Copied to clipboard!
await context.accessors.trigger('eventSayHello', 'World');