UNPKG

@tanstack/db

Version:

A reactive client store for building super fast apps on sync

61 lines (60 loc) 1.5 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const eventEmitter = require("../event-emitter.cjs"); class CollectionEventsManager extends eventEmitter.EventEmitter { constructor() { super(); } setDeps(deps) { this.collection = deps.collection; } /** * Emit an event to all listeners * Public API for emitting collection events */ emit(event, eventPayload) { this.emitInner(event, eventPayload); } emitStatusChange(status, previousStatus) { this.emit(`status:change`, { type: `status:change`, collection: this.collection, previousStatus, status }); const eventKey = `status:${status}`; this.emit(eventKey, { type: eventKey, collection: this.collection, previousStatus, status }); } emitSubscribersChange(subscriberCount, previousSubscriberCount) { this.emit(`subscribers:change`, { type: `subscribers:change`, collection: this.collection, previousSubscriberCount, subscriberCount }); } emitIndexAdded(index) { this.emit(`index:added`, { type: `index:added`, collection: this.collection, index }); } emitIndexRemoved(index) { this.emit(`index:removed`, { type: `index:removed`, collection: this.collection, index }); } cleanup() { this.clearListeners(); } } exports.CollectionEventsManager = CollectionEventsManager; //# sourceMappingURL=events.cjs.map