UNPKG

@adaptabletools/adaptable-cjs

Version:

Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

35 lines (34 loc) 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EventApiImpl = void 0; const tslib_1 = require("tslib"); const ApiBase_1 = require("./ApiBase"); const Emitter_1 = tslib_1.__importDefault(require("../../Utilities/Emitter")); const EventInternalApi_1 = require("../Internal/EventInternalApi"); class EventApiImpl extends ApiBase_1.ApiBase { constructor(_adaptable) { super(_adaptable); this.on = (eventName, callback) => { let result; if (eventName === 'AdaptableReady') { this.emitter.onIncludeFiredOnce(eventName).then(callback); return () => { }; } else { result = this.emitter.on(eventName, callback); } return result; }; this.off = (eventName, callback) => this.emitter.off(eventName, callback); this.emit = (eventName, data) => this.emitter.emit(eventName, data); this.emitSync = (eventName, data) => this.emitter.emitSync(eventName, data); this.emitter = new Emitter_1.default(); this.internalApi = new EventInternalApi_1.EventInternalApi(_adaptable); } destroy() { super.destroy(); this.emitSync('AdaptableDestroy'); this.emitter.destroy(); } } exports.EventApiImpl = EventApiImpl;