@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 Parameter | Description |
|---|---|
T | The shape of the application state. |
Properties
broadcastSaves?
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
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()?
optional onClear: (fromTabId) => void;Defined in: persistence/src/cross-tab.ts:138
Called when another tab notifies that it has cleared its storage.
Parameters
| Parameter | Type | Description |
|---|---|---|
fromTabId | string | The unique identifier of the tab that cleared storage. |
Returns
void
onSnapshot()?
optional onSnapshot: (snapshot, fromTabId) => void;Defined in: persistence/src/cross-tab.ts:123
Called when a snapshot is received from another tab.
Parameters
| Parameter | Type | Description |
|---|---|---|
snapshot | SnapshotEnvelope<T> | The snapshot envelope broadcast by the other tab. |
fromTabId | string | The unique identifier of the sending tab. |
Returns
void
onSyncRequest()?
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
| Parameter | Type | Description |
|---|---|---|
fromTabId | string | The unique identifier of the requesting tab. |
Returns
void
receiveUpdates?
optional receiveUpdates: boolean;Defined in: persistence/src/types.ts:740
Whether this tab should apply snapshots received from other tabs.
Default Value
true
