Skip to content

Leader Election

Elect one tab to own background work.

Implementation

ts
lifecycle.on("tab:primary", () => becomeLeader());
lifecycle.on("tab:secondary", () => resignLeadership());

Testing

Open multiple tabs and verify promotion when the leader closes.

Playground

Cross Tab Playground

Tutorial

Advanced Tutorial

JOC is a JayOnCode monorepo of @jayoncode/* packages. Docs sync from source via TypeDoc and sync scripts.