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 #

trigger(event, [payload]);

ArgumentsTypeDescription
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);
  }
}