Skip to content

LocalStateStorage

Defined in: src/client/state-storage.ts:177

State in localStorage, so every tab of an origin agrees on it and it survives a reload.

The two fields are written as <principal>|<expiration> rather than JSON, because an expiration is a bigint and JSON has no way to carry one.

implements StateStorage

new LocalStateStorage(): LocalStateStorage

LocalStateStorage

discard(key): void

Defined in: src/client/state-storage.ts:213

The same as remove: this store publishes nothing beyond the origin.

string

void

StateStorage.discard


get(key): SessionState | null

Defined in: src/client/state-storage.ts:183

The state, or null where nothing is signed in within this store’s reach.

string

SessionState | null

StateStorage.get


remove(key): void

Defined in: src/client/state-storage.ts:207

Removes the state, and anything this store publishes beyond this origin.

What signing out does: the user ended the sign-in, so a sibling reading a shared record must stop seeing one.

string

void

StateStorage.remove


set(key, state): void

Defined in: src/client/state-storage.ts:202

string

Omit<SessionState, "held">

void

StateStorage.set


subscribe(key, listener): () => void

Defined in: src/client/state-storage.ts:225

Fires when the state changes, here or in another tab of this origin.

localStorage raises storage in every tab except the one that wrote, so that event carries a change between tabs and a same-tab write is announced directly. Either way the record is readable before it is announced, so a listener asking who is signed in sees what it was told about.

string

() => void

() => void

StateStorage.subscribe