Core
Write Plugins v1.x
1

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