The plugin implement this interface will be called when an event is broadcasted.

class RedisBroadcastPlugin implements BroadcastPlugin {
async broadcast(ctx, event, next) {
await redis.publish('events', JSON.stringify(event));
return next();
}
}
interface BroadcastPlugin {
    broadcast(event: Event, next: (() => Promise<void>)): Promise<void>;
}

Methods

Methods

  • This method functions like Koa middleware and is called when an event is broadcasted.

    Parameters

    • event: Event

      The event to broadcast

    • next: (() => Promise<void>)

      The next function to call the next plugin

        • (): Promise<void>
        • Returns Promise<void>

    Returns Promise<void>