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
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new LocalStateStorage():
LocalStateStorage
Returns
Section titled “Returns”LocalStateStorage
Methods
Section titled “Methods”discard()
Section titled “discard()”discard(
key):void
Defined in: src/client/state-storage.ts:213
The same as remove: this store publishes nothing beyond the origin.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”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.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”SessionState | null
Implementation of
Section titled “Implementation of”remove()
Section titled “remove()”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.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”set(
key,state):void
Defined in: src/client/state-storage.ts:202
Parameters
Section titled “Parameters”string
Omit<SessionState, "held">
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”subscribe()
Section titled “subscribe()”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.
Parameters
Section titled “Parameters”string
listener
Section titled “listener”() => void
Returns
Section titled “Returns”() => void