-
Notifications
You must be signed in to change notification settings - Fork 1
Event queue broadcasting
einarhuseby edited this page May 4, 2023
·
2 revisions
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'}));