Skip to main content

Interface: UseTabLeaderReturn<TMessage>

Defined in: use-tab-leader.ts:45

Value returned by useTabLeader.

Type Parameters​

TMessage​

TMessage = unknown

Properties​

broadcast​

broadcast: (message) => void

Defined in: use-tab-leader.ts:69

Sends message to every other tab (and hook instance) using the same key, which receive it in onMessage. It is how the leader hands its results to the followers. The value must be structured-cloneable, or this throws. It does nothing without BroadcastChannel. Stable identity.

Parameters​

message​

TMessage

Returns​

void


id​

id: string | null

Defined in: use-tab-leader.ts:62

A random id for this hook instance, or null until the effect has run (and while enabled is false). Every instance gets its own id, also when several share a tab. It changes when key changes.


isLeader​

isLeader: boolean

Defined in: use-tab-leader.ts:50

true while this hook instance is the leader. It is false during server rendering and on the first render, until the election has run.


leaderId​

leaderId: string | null

Defined in: use-tab-leader.ts:56

The id of the current leader, or null while it is not known: no leader has been elected yet, or this tab can't learn who the leader is because BroadcastChannel is missing.