json-joy
Version:
Collection of libraries for building collaborative editing apps.
26 lines (25 loc) • 841 B
JavaScript
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;
;