@tanstack/db
Version:
A reactive client store for building super fast apps on sync
47 lines (46 loc) • 1.21 kB
JavaScript
;
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
});
}
cleanup() {
this.clearListeners();
}
}
exports.CollectionEventsManager = CollectionEventsManager;
//# sourceMappingURL=events.cjs.map