"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NodeEvents = void 0;
const fanout_1 = require("./fanout");
class NodeEvents {
    constructor(api) {
        this.api = api;
        // ---------------------------------------------------------------- SyncStore
        this.subscribe = (callback) => this.onViewChanges.listen(() => callback());
        this.getSnapshot = () => this.api.view();
        this.onChanges = new fanout_1.MapFanOut(this.api.api.onChanges, this.getSnapshot);
        this.onViewChanges = new fanout_1.OnNewFanOut(this.onChanges, this.api.view());
    }
    /**
     * Called when this node is deleted.
     *
     * @internal
     * @ignore
     */
    handleDelete() {
        this.onViewChanges.clear();
        this.onChanges.clear();
    }
}
exports.NodeEvents = NodeEvents;
//# sourceMappingURL=NodeEvents.js.map