@tanstack/db
Version:
A reactive client store for building super fast apps on sync
47 lines (46 loc) • 1.09 kB
JavaScript
import { EventEmitter } from "../event-emitter.js";
class CollectionEventsManager extends 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();
}
}
export {
CollectionEventsManager
};
//# sourceMappingURL=events.js.map