2020-02-04 09:43:22 +00:00
|
|
|
import { EventEmitter } from 'events';
|
|
|
|
import * as _ from 'lodash';
|
|
|
|
import StrictEventEmitter from 'strict-event-emitter-types';
|
2020-04-01 09:40:34 +00:00
|
|
|
import { TargetState } from './types/state';
|
2020-02-04 09:43:22 +00:00
|
|
|
|
|
|
|
export interface GlobalEvents {
|
|
|
|
deviceProvisioned: void;
|
2020-04-01 09:40:34 +00:00
|
|
|
targetStateChanged: TargetState;
|
2020-02-04 09:43:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type GlobalEventEmitter = StrictEventEmitter<EventEmitter, GlobalEvents>;
|
|
|
|
|
|
|
|
export class GlobalEventBus extends (EventEmitter as new () => GlobalEventEmitter) {
|
|
|
|
public constructor() {
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const getInstance = _.once(() => new GlobalEventBus());
|