Write Plugins v2.x

# trigger

Triggers a custom event.

This allows interactions with other 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(event, [payload]);

Arguments Type Description
Custom event name
Event payload

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

# Example

Copied to clipboard!
// somewhere in the emitting plugin, named "emitting-plugin" in the manifest

const result = await context.accessors.trigger('sayHello', 'World');
// => "Hello, World"

// [...]

// Listening plugin
class ListeningPlugin {
  constructor() {
    this.pipes = {
      'plugin-emitting-plugin:sayHello': async name => {
        return `Hello, ${name}`;