export class EventEmitter {
    constructor() {
        this.listeners = new Map();
    }
    on(event, listener) {
        this.listeners.getOrAdd(event, () => new Set()).add(listener);
    }
    once(event, listener) {
        const onceListener = data => {
            this.off(event, onceListener);
            listener(data);
        };
        this.on(event, onceListener);
    }
    off(event, listener) {
        var _a;
        (_a = this.listeners.get(event)) === null || _a === void 0 ? void 0 : _a.delete(listener);
    }
    emit(event, data) {
        var _a;
        (_a = this.listeners.get(event)) === null || _a === void 0 ? void 0 : _a.forEach(listener => listener(data));
    }
    dispose() {
        this.listeners.clear();
    }
}
//# sourceMappingURL=observable.js.map