UNPKG

lavva.exalushome

Version:

Library implementing communication and abstraction layers for ExalusHome system

25 lines 695 B
import { DependencyContainer } from './DependencyContainer'; export class TypedEvent { constructor() { this.handlers = []; } Subscribe(handler) { if (!this.handlers.includes(handler)) this.handlers.push(handler); } Unsubscribe(handler) { this.handlers = this.handlers.filter(h => h !== handler); } Invoke(data) { this.handlers.slice(0).forEach(h => { var _a; try { h(data); } catch (ex) { (_a = DependencyContainer.Log) === null || _a === void 0 ? void 0 : _a.Error(ex); } }); } } //# sourceMappingURL=TypedEvent.js.map