@adaptabletools/adaptable
Version:
Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
30 lines (29 loc) • 1.1 kB
JavaScript
import { ApiBase } from './ApiBase';
import Emitter from '../../Utilities/Emitter';
import { EventInternalApi } from '../Internal/EventInternalApi';
export class EventApiImpl extends 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();
this.internalApi = new EventInternalApi(_adaptable);
}
destroy() {
super.destroy();
this.emitSync('AdaptableDestroy');
this.emitter.destroy();
}
}