balena-supervisor/src/event-bus.ts
Cameron Diver 0a429f60a5 Add newTargetState event and use it for backup loading
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
2020-04-07 14:50:34 +01:00

20 lines
534 B
TypeScript

import { EventEmitter } from 'events';
import * as _ from 'lodash';
import StrictEventEmitter from 'strict-event-emitter-types';
import { TargetState } from './types/state';
export interface GlobalEvents {
deviceProvisioned: void;
targetStateChanged: TargetState;
}
type GlobalEventEmitter = StrictEventEmitter<EventEmitter, GlobalEvents>;
export class GlobalEventBus extends (EventEmitter as new () => GlobalEventEmitter) {
public constructor() {
super();
}
}
export const getInstance = _.once(() => new GlobalEventBus());