Files
smartuniverse/ts/smartuniverse.classes.event.broadcastevent.ts
T

18 lines
523 B
TypeScript
Raw Normal View History

2023-07-25 11:33:13 +02:00
import * as plugins from './smartuniverse.plugins.js';
2019-09-25 18:26:39 +02:00
/**
* broadcasts an event to multiple channels
2020-09-29 19:39:13 +00:00
* also handles subscription
2019-09-25 18:26:39 +02:00
*/
2020-09-24 18:13:48 +00:00
export class BroadcastEvent<T extends plugins.typedrequestInterfaces.ITypedEvent<any>> {
2019-11-10 16:55:17 +01:00
public eventSubject = new plugins.smartrx.rxjs.Subject<T['payload']>();
2020-09-24 18:17:52 +00:00
constructor() {}
2019-11-10 16:55:17 +01:00
2020-09-24 18:17:52 +00:00
public fire(eventPayloadArg: T['payload']) {}
2019-11-10 16:55:17 +01:00
public subscribe(funcArg: (nextArg: T['payload']) => void): plugins.smartrx.rxjs.Subscription {
return this.eventSubject.subscribe(funcArg);
}
2019-11-09 13:00:30 +01:00
}