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(); }} Copy
class RedisBroadcastPlugin implements BroadcastPlugin { async broadcast(ctx, event, next) { await redis.publish('events', JSON.stringify(event)); return next(); }}
This method functions like Koa middleware and is called when an event is broadcasted.
The event to broadcast
The next function to call the next plugin
The plugin implement this interface will be called when an event is broadcasted.
Example