lavva.exalushome
Version:
Library implementing communication and abstraction layers for ExalusHome system
25 lines • 636 B
JavaScript
import { Api } from './Api';
import { LoggerService } from './Services/Logging/LoggerService';
export class Event {
constructor() {
this._log = Api.Get(LoggerService.ServiceName);
this.handlers = [];
}
Subscribe(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