Core
Write Plugins v1.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

trigger #

Triggers a custom event.

This allows interactions with other plugins using hooks or pipes.

Arguments #

Copied to clipboard!
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 #

Copied to clipboard!
// 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);
  }
}