Skip to main content

Class: CollectionSubscription<T>

A live view of a collection. Holds the full current array, kept in sync via an initial REST snapshot plus SSE events. Register listeners with onSnapshot / onError; read current synchronously; call unsubscribe to tear down (and release the shared connection).

Type Parameters

Type Parameter
T

Constructors

new CollectionSubscription()

new CollectionSubscription<T>(connection, cfg): CollectionSubscription<T>

Internal

Parameters

ParameterType
connectionRealtimeConnection
cfgCollectionWatchConfig<T>

Returns

CollectionSubscription<T>

Defined in

4Players/cortex-typescript-sdk/src/realtime/watch.ts:105

Accessors

current

get current(): T[]

The latest known array. Empty until the initial snapshot resolves.

Returns

T[]

Defined in

4Players/cortex-typescript-sdk/src/realtime/watch.ts:116

Methods

onError()

onError(cb): () => void

Register an error listener.

Parameters

ParameterType
cbErrorListener

Returns

Function

A disposer that removes this listener.

Returns

void

Defined in

4Players/cortex-typescript-sdk/src/realtime/watch.ts:140


onSnapshot()

onSnapshot(cb): () => void

Register a snapshot listener. Fires immediately with the current state if the initial snapshot has already loaded, then on every change.

Parameters

ParameterType
cbCollectionSnapshotListener<T>

Returns

Function

A disposer that removes this listener.

Returns

void

Defined in

4Players/cortex-typescript-sdk/src/realtime/watch.ts:125


unsubscribe()

unsubscribe(): void

Tear down: stop listening and release the shared connection.

Returns

void

Defined in

4Players/cortex-typescript-sdk/src/realtime/watch.ts:148