MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / createRuntimeLocalStateStore

Function createRuntimeLocalStateStore

packages/core/src/runtime/localState.ts:217–239  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

215
216/** Create a new local state store instance. */
217export function createRuntimeLocalStateStore(): RuntimeLocalStateStore {
218 const table = new Map<InstanceId, RuntimeLocalState>();
219
220 return Object.freeze({
221 get: (instanceId) => table.get(instanceId),
222 set: (instanceId, patch) => {
223 const prev = table.get(instanceId) ?? DEFAULT_STATE;
224 const next: RuntimeLocalState = {
225 layout: patch.layout !== undefined ? patch.layout : prev.layout,
226 hover: patch.hover !== undefined ? patch.hover : prev.hover,
227 pressed: patch.pressed !== undefined ? patch.pressed : prev.pressed,
228 focusable: patch.focusable !== undefined ? patch.focusable : prev.focusable,
229 tabIndex: patch.tabIndex !== undefined ? patch.tabIndex : prev.tabIndex,
230 };
231 const frozen = freezeState(next);
232 table.set(instanceId, frozen);
233 return frozen;
234 },
235 delete: (instanceId) => {
236 table.delete(instanceId);
237 },
238 });
239}
240
241/* ========== Virtual List State Store ========== */
242

Callers 1

Calls 4

freezeStateFunction · 0.70
getMethod · 0.45
setMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected