📄 tanstack/db/latest/docs/reference/interfaces/Subscription

File: Subscription.md | Updated: 11/15/2025

Source: https://tanstack.com/db/latest/docs/reference/interfaces/Subscription



TanStack

DB v0v0

Search...

+ K

Auto

Log In

TanStack StartRC

Docs Examples GitHub Contributors

TanStack Router

Docs Examples GitHub Contributors

TanStack Query

Docs Examples GitHub Contributors

TanStack Table

Docs Examples Github Contributors

TanStack Formnew

Docs Examples Github Contributors

TanStack DBbeta

Docs Github Contributors

TanStack Virtual

Docs Examples Github Contributors

TanStack Paceralpha

Docs Examples Github Contributors

TanStack Storealpha

Docs Examples Github Contributors

TanStack Devtoolsalpha

Docs Github Contributors

More Libraries

Maintainers Partners Support Learn StatsBETA Discord Merch Blog GitHub Ethos Brand Guide

Documentation

Framework

React logo

React

Version

Latest

Search...

+ K

Menu

Getting Started

Guides

Collections

Frameworks

Community

API Reference

Framework

React logo

React

Version

Latest

Menu

Getting Started

Guides

Collections

Frameworks

Community

API Reference

On this page

Subscription

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

Extends
-------

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

#### Returns

void

#### Inherited from

ts

EventEmitter.clearListeners


EventEmitter.clearListeners

### emitInner()

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

#### Type Parameters ##### T

T extends keyof SubscriptionEvents

#### Parameters ##### event

T

Event name to emit

##### eventPayload

SubscriptionEvents [T]

Event payload For use by subclasses - subclasses should wrap this with a public emit if needed

#### Returns

void

#### Inherited from

ts

EventEmitter.emitInner


EventEmitter.emitInner

### off()

ts

off<T>(event, callback): void;


off<T>(event, callback): void;

Defined in: packages/db/src/event-emitter.ts:53

Unsubscribe from an event

#### Type Parameters ##### T

T extends keyof SubscriptionEvents

#### Parameters ##### event

T

Event name to stop listening for

##### callback

(event) => void

Function to remove

#### Returns

void

#### Inherited from

ts

EventEmitter.off


EventEmitter.off

### on()

ts

on<T>(event, callback): () => void;


on<T>(event, callback): () => void;

Defined in: packages/db/src/event-emitter.ts:17

Subscribe to an event

#### Type Parameters ##### T

T extends keyof SubscriptionEvents

#### Parameters ##### event

T

Event name to listen for

##### callback

(event) => void

Function to call when event is emitted

#### Returns

Unsubscribe function

ts

(): void;


(): void;

##### Returns

void

#### Inherited from

ts

EventEmitter.on


EventEmitter.on

### once()

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)

#### Type Parameters ##### T

T extends keyof SubscriptionEvents

#### Parameters ##### event

T

Event name to listen for

##### callback

(event) => void

Function to call when event is emitted

#### Returns

Unsubscribe function

ts

(): void;


(): void;

##### Returns

void

#### Inherited from

ts

EventEmitter.once


EventEmitter.once

### waitFor()

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

#### Type Parameters ##### T

T extends keyof SubscriptionEvents

#### Parameters ##### event

T

Event name to wait for

##### timeout?

number

Optional timeout in milliseconds

#### Returns

Promise<SubscriptionEvents [T]>

Promise that resolves with the event payload

#### Inherited from

ts

EventEmitter.waitFor


EventEmitter.waitFor

Edit on GitHub

Home

Partners Become a Partner

Code RabbitCode Rabbit CloudflareCloudflare AG GridAG Grid NetlifyNetlify NeonNeon WorkOSWorkOS ClerkClerk ConvexConvex ElectricElectric SentrySentry PrismaPrisma StrapiStrapi UnkeyUnkey

scarf analytics