EnvironmentSessionState
A scoped view over the session store: one environment's state, or one scene's.
@internote/canvas-sdkimport { EnvironmentSessionState } from '@internote/canvas-sdk';What ctx.storage.session is. In a surface, read it through useEnvironmentSession, which subscribes and re-renders.
#Fields
clearDeletes the state and notifies subscribers.
voidgetReturns the current state, or
undefined before anything was written.S | undefinedsetReplaces the state and notifies subscribers.
voidsubscribeCalls the listener after every write to this state, and returns the unsubscribe.
() => voidupdateReplaces the state with what the updater returns from the previous one, and notifies subscribers.
void#Example
const state = (ctx.storage.session.get() as GreetingState | undefined) ?? initialState();
ctx.storage.session.update((previous) => ({ ...(previous as GreetingState), waves: state.waves + 1 }));Declared in packages/canvas-sdk/src/storage/session.ts:87.