MCPcopy Index your code
hub / github.com/tinyplex/tinybase / getValue

Function getValue

src/ui-svelte/functions.svelte.ts:543–564  ·  view source on GitHub ↗
(
  valueId: MaybeGetter<Id>,
  storeOrStoreId?: MaybeGetter<Store | Id | undefined>,
)

Source from the content-addressed store, hash-verified

541 );
542
543export const getValue = (
544 valueId: MaybeGetter<Id>,
545 storeOrStoreId?: MaybeGetter<Store | Id | undefined>,
546): {get current(): ValueOrUndefined; set current(v: Value)} => {
547 const getStore = resolveStore(storeOrStoreId);
548 let subscribe = $state<() => void>(noop);
549 if (hasWindow()) {
550 $effect(() => {
551 const store: any = getStore();
552 const valueIdValue = maybeGet(valueId);
553 subscribe = createSubscriber((update) => {
554 const listenerId = store?.addValueListener(valueIdValue, update);
555 return () => store?.delListener?.(listenerId);
556 });
557 });
558 }
559 return new WritableHandle<ValueOrUndefined, Value>(
560 () => getStore()?.getValue(maybeGet(valueId)),
561 (nextValue) => getStore()?.setValue(maybeGet(valueId), nextValue),
562 () => subscribe(),
563 );
564};
565
566export const getStore = (id?: Id): Store | undefined =>
567 getProvidedThing(id, OFFSET_STORE) as Store | undefined;

Callers 15

contentFunction · 0.90
contentFunction · 0.90
contentFunction · 0.90
CellViewFunction · 0.90
MetricViewFunction · 0.90
contentFunction · 0.90
useThingFunction · 0.90
useThingOrThingByIdFunction · 0.90
contentFunction · 0.90
contentFunction · 0.90
contentFunction · 0.90
CheckpointViewFunction · 0.90

Calls 8

hasWindowFunction · 0.90
resolveStoreFunction · 0.70
getStoreFunction · 0.70
maybeGetFunction · 0.70
addValueListenerMethod · 0.65
delListenerMethod · 0.65
getValueMethod · 0.65
setValueMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…