mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-01-03 12:34:11 +00:00
0a429f60a5
Change-type: patch Signed-off-by: Cameron Diver <cameron@balena.io>
20 lines
534 B
TypeScript
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());
|