trigger #
Triggers a custom event.
This allows interactions with other plugins using hooks or pipes.
Arguments #
trigger(event, [payload]);
Arguments | Type | Description |
---|---|---|
event | string | Custom event name |
payload | object | Event payload |
Note: the triggered event is renamed using the following format:plugin-<plugin name>:<event>
.
Example #
// Emitting plugin, named "some-plugin"
context.accessors.trigger('someEvent', {
someAttribute: 'someValue'
});
// Listening plugin
class ListeningPlugin {
constructor() {
this.hooks = {
'plugin-some-plugin:someEvent': 'someEventListener'
};
}
someEventListener(payload) {
this.doSomething(payload);
}
}
Edit this page on Github(opens new window)