Skip to content

Documentation / @etherfold/browser / TabElection

Type Alias: TabElection ​

TabElection = object

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

THE ELECTION AN APP OPTS INTO: the name of the one lock its tabs contend for.

Named by the APP, exactly as a SharedWorker's name is, and not derived from a store's storage identity: the election decides which TAB indexes, and one host holds several generations with a store each, so a lock per store would have one tab holding the canonical generation's lock and not its successor's. Two apps on one origin supply two names and never contend.

The election is ON only when the app supplies this AND a reader factory (openState), and only where navigator.locks exists. Anywhere else a host behaves exactly as it did before this existed (D3).

Properties ​

foregroundTakeover? ​

readonly optional foregroundTakeover?: boolean | ForegroundTakeover

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

A VISIBLE TAB TAKES THE LEASE FROM A BACKGROUNDED LEADER (ADR-0097, D4 as amended). ON by default whenever the election is on; false keeps the first cut's behaviour, where the tab that indexes keeps the lock until it closes.

A browser throttles a tab nobody is looking at and freezes one hidden for long, and the lock does not notice: without this, the tab the user IS looking at is a reader whose data falls behind a leader that indexes slowly or not at all. With it, a READER whose tab has stayed visible for settleMs while the leader is hidden (or has never been heard, which is what a FROZEN leader looks like) takes the lock with steal, and the leader it displaced stops, abandons its in-flight batch and goes back to reading. A visible leader is never displaced, and a quick switch between tabs moves nothing.


name ​

readonly name: string

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

The app's election name. Tabs that give the same name elect ONE indexing tab among themselves.