Skip to content

@statesync/persistence


@statesync/persistence / CrossTabSyncHandlers

Interface: CrossTabSyncHandlers<T>

Defined in: persistence/src/cross-tab.ts:116

Configuration and event handlers for createCrossTabSync.

Extends CrossTabSyncOptions with callback handlers for each type of cross-tab message.

Extends

Type Parameters

Type ParameterDescription
TThe shape of the application state.

Properties

broadcastSaves?

ts
optional broadcastSaves: boolean;

Defined in: persistence/src/types.ts:747

Whether this tab should broadcast its saves to other tabs.

Default Value

true

Inherited from

CrossTabSyncOptions.broadcastSaves


channelName

ts
channelName: string;

Defined in: persistence/src/types.ts:733

The name of the BroadcastChannel used for inter-tab communication.

All tabs that should synchronize state must use the same channel name. Convention: 'state-sync:<topic>'.

Inherited from

CrossTabSyncOptions.channelName


onClear()?

ts
optional onClear: (fromTabId) => void;

Defined in: persistence/src/cross-tab.ts:138

Called when another tab notifies that it has cleared its storage.

Parameters

ParameterTypeDescription
fromTabIdstringThe unique identifier of the tab that cleared storage.

Returns

void


onSnapshot()?

ts
optional onSnapshot: (snapshot, fromTabId) => void;

Defined in: persistence/src/cross-tab.ts:123

Called when a snapshot is received from another tab.

Parameters

ParameterTypeDescription
snapshotSnapshotEnvelope<T>The snapshot envelope broadcast by the other tab.
fromTabIdstringThe unique identifier of the sending tab.

Returns

void


onSyncRequest()?

ts
optional onSyncRequest: (fromTabId) => void;

Defined in: persistence/src/cross-tab.ts:131

Called when another tab sends a sync request, asking this tab to broadcast its latest state.

Parameters

ParameterTypeDescription
fromTabIdstringThe unique identifier of the requesting tab.

Returns

void


receiveUpdates?

ts
optional receiveUpdates: boolean;

Defined in: persistence/src/types.ts:740

Whether this tab should apply snapshots received from other tabs.

Default Value

true

Inherited from

CrossTabSyncOptions.receiveUpdates

Released under the MIT License.