UNPKG

lavva.exalushome

Version:

Library implementing communication and abstraction layers for ExalusHome system

26 lines 686 B
import { Api } from './Api'; import { LoggerService } from './Services/Logging/LoggerService'; export class Event { constructor() { this._log = Api.Get(LoggerService.ServiceName); this.handlers = []; } Subscribe(handler) { if (!this.handlers.includes(handler)) this.handlers.push(handler); } Unsubscribe(handler) { this.handlers = this.handlers.filter(h => h !== handler); } Invoke() { this.handlers.slice(0).forEach(h => { try { h(); } catch (ex) { this._log.Error(ex); } }); } } //# sourceMappingURL=Event.js.map