File: Subscription.md | Updated: 11/15/2025
Search...
+ K
Auto
Docs Examples GitHub Contributors
Docs Examples GitHub Contributors
Docs Examples GitHub Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Maintainers Partners Support Learn StatsBETA Discord Merch Blog GitHub Ethos Brand Guide
Documentation
Framework
React
Version
Latest
Search...
+ K
Menu
Getting Started
Guides
Collections
Frameworks
Community
API Reference
Framework
React
Version
Latest
Menu
Getting Started
Guides
Collections
Frameworks
Community
API Reference
On this page
Copy Markdown
Interface: Subscription
=======================
Defined in: packages/db/src/types.ts:232
Public interface for a collection subscription Used by sync implementations to track subscription lifecycle
Properties
----------
### status
ts
readonly status: SubscriptionStatus;
readonly status: SubscriptionStatus;
Defined in: packages/db/src/types.ts:234
Current status of the subscription
Methods
-------
### clearListeners()
ts
protected clearListeners(): void;
protected clearListeners(): void;
Defined in: packages/db/src/event-emitter.ts:115
Clear all listeners
void
ts
EventEmitter.clearListeners
EventEmitter.clearListeners
ts
protected emitInner<T>(event, eventPayload): void;
protected emitInner<T>(event, eventPayload): void;
Defined in: packages/db/src/event-emitter.ts:96
Internal
Emit an event to all listeners
T extends keyof SubscriptionEvents
T
Event name to emit
Event payload For use by subclasses - subclasses should wrap this with a public emit if needed
void
ts
EventEmitter.emitInner
EventEmitter.emitInner
ts
off<T>(event, callback): void;
off<T>(event, callback): void;
Defined in: packages/db/src/event-emitter.ts:53
Unsubscribe from an event
T extends keyof SubscriptionEvents
T
Event name to stop listening for
(event) => void
Function to remove
void
ts
EventEmitter.off
EventEmitter.off
ts
on<T>(event, callback): () => void;
on<T>(event, callback): () => void;
Defined in: packages/db/src/event-emitter.ts:17
Subscribe to an event
T extends keyof SubscriptionEvents
T
Event name to listen for
(event) => void
Function to call when event is emitted
Unsubscribe function
ts
(): void;
(): void;
void
ts
EventEmitter.on
EventEmitter.on
ts
once<T>(event, callback): () => void;
once<T>(event, callback): () => void;
Defined in: packages/db/src/event-emitter.ts:37
Subscribe to an event once (automatically unsubscribes after first emission)
T extends keyof SubscriptionEvents
T
Event name to listen for
(event) => void
Function to call when event is emitted
Unsubscribe function
ts
(): void;
(): void;
void
ts
EventEmitter.once
EventEmitter.once
ts
waitFor<T>(event, timeout?): Promise<SubscriptionEvents[T]>;
waitFor<T>(event, timeout?): Promise<SubscriptionEvents[T]>;
Defined in: packages/db/src/event-emitter.ts:66
Wait for an event to be emitted
T extends keyof SubscriptionEvents
T
Event name to wait for
number
Optional timeout in milliseconds
Promise<SubscriptionEvents [T]>
Promise that resolves with the event payload
ts
EventEmitter.waitFor
EventEmitter.waitFor
