Event queue broadcasting - luftsport/nlf-client GitHub Wiki

This is a simple event queue broadcasting via RxJs' subject

The broadcast messages are typed as AppEventType (enum) and AppEvent is the initializing class.

AppEvent takes two parameter, typeand payload. typeis ofAppEventTypetype andpayload` is any.


// Import it
import { NlfEventQueueService, AppEventType } from 'app/nlf-event-queue.service';

// Init it
constructor (private eventQueue: NlfEventQueueService) {}

// Observe it
this.eventQueue.on(AppEventType.ObsregEvent).subscribe(event => this._handleEvent(event.payload));

// Broadcast
this.eventQueue.dispatch(new AppEvent(AppEventType.ObsregEvent, {action: 'force_save'}));