import { EventEmitter } from 'events' ; import { PubSub } from './pubSub' ; /**
 * Creates a PubSub which broadcasts messages only locally - within the current process.
 */ export function createPubSub ( ) { return new LocalPubSub ( ) ; } class LocalPubSub implements PubSub { private readonly hub : EventEmitter = new EventEmitter ( ) ; public subscribe ( channel , callback ) { this . hub . on ( channel , callback ) ; } public unsubscribe ( channel , callback ) { this . hub . off ( channel , callback ) ; } public publish ( channel , message ) { this . hub . emit ( channel , message ) ; } }