Skip to main content

SyncStream

A handle to a SyncStreamDescription that allows subscribing to the stream.

To obtain an instance of SyncStream, call CommonPowerSyncDatabase.syncStream.

Extends

Properties

PropertyTypeDescriptionInherited from
namestringThe name of the stream as it appears in the stream definition for the PowerSync service.SyncStreamDescription.name
parametersRecord<string, any> | nullThe parameters used to subscribe to the stream, if any. The same stream can be subscribed to multiple times with different parameters.SyncStreamDescription.parameters

Methods

subscribe()

subscribe(options?): Promise<SyncStreamSubscription>;

Adds a subscription to this stream, requesting it to be included when connecting to the sync service.

You should keep a reference to the returned SyncStreamSubscription object along as you need data for that stream. As soon as SyncStreamSubscription.unsubscribe is called for all subscriptions on this stream (including subscriptions created on other tabs), the SyncStreamSubscribeOptions.ttl starts ticking and will eventually evict the stream (unless SyncStream.subscribe is called again).

Parameters

ParameterType
options?SyncStreamSubscribeOptions

Returns

Promise<SyncStreamSubscription>


unsubscribeAll()

unsubscribeAll(): Promise<void>;

Clears all subscriptions attached to this stream and resets the TTL for the stream.

This is a potentially dangerous operations, as it interferes with other stream subscriptions.

Returns

Promise<void>