Skip to content

Documentation / @etherfold/browser / TabElectionState

Type Alias: TabElectionState ​

TabElectionState = object

Defined in: packages/browser/src/tabElection.ts:111

WHAT THE ELECTION HAS MADE OF THIS HOST, reported beside the progress an app already renders (HostProgress.election on a port, SyncingState.election on the main-thread hook).

ABSENT where the election is off, so an app that never opted in sees nothing new.

Properties ​

displaced? ​

readonly optional displaced?: boolean

Defined in: packages/browser/src/tabElection.ts:132

true on a READER that was the writer until a visible tab took the lease from it (foregroundTakeover): it stopped, abandoned its in-flight batch, and reads.


name ​

readonly name: string

Defined in: packages/browser/src/tabElection.ts:113

The election this host stood in (TabElection.name).


role ​

readonly role: TabElectionRole

Defined in: packages/browser/src/tabElection.ts:119

reader while another tab holds the lock: this host fetches nothing, claims nothing, answers reads from the shared store and reports the LEADER's progress. writer once it holds the lock and indexes.


takeoverReason? ​

readonly optional takeoverReason?: TakeoverReason

Defined in: packages/browser/src/tabElection.ts:127

WHY this host took over, present exactly when tookOver is.


tookOver ​

readonly tookOver: boolean

Defined in: packages/browser/src/tabElection.ts:125

Whether this host TOOK OVER: it became the writer after having waited behind another tab that held the lock (which closed, crashed or was killed). false for a host that found the lock free and led from the start.


visibility? ​

readonly optional visibility?: TabVisibility

Defined in: packages/browser/src/tabElection.ts:140

WHAT THIS HOST KNOWS OF ITS TAB'S VISIBILITY, which a leader publishes so a visible reader can tell whether to take the lease. ABSENT where the host does not take part in the foreground takeover (turned off, a SharedWorker host, or a worker no tab has reported to), and a leader that publishes none is never displaced.