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()
Internal
Parameters
| Parameter | Type |
|---|---|
connection | RealtimeConnection |
cfg | CollectionWatchConfig<T> |
Returns
Defined in
4Players/cortex-typescript-sdk/src/realtime/watch.ts:105
Accessors
current
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()
Register an error listener.
Parameters
| Parameter | Type |
|---|---|
cb | ErrorListener |
Returns
Function
A disposer that removes this listener.
Returns
void
Defined in
4Players/cortex-typescript-sdk/src/realtime/watch.ts:140
onSnapshot()
Register a snapshot listener. Fires immediately with the current state if the initial snapshot has already loaded, then on every change.
Parameters
| Parameter | Type |
|---|---|
cb | CollectionSnapshotListener<T> |
Returns
Function
A disposer that removes this listener.
Returns
void
Defined in
4Players/cortex-typescript-sdk/src/realtime/watch.ts:125
unsubscribe()
Tear down: stop listening and release the shared connection.
Returns
void
Defined in
4Players/cortex-typescript-sdk/src/realtime/watch.ts:148