MCPcopy
hub / github.com/wavetermdev/waveterm / useBlockAtom

Function useBlockAtom

frontend/app/store/global.ts:335–343  ·  view source on GitHub ↗
(blockId: string, name: string, makeFn: () => Atom<T>)

Source from the content-addressed store, hash-verified

333}
334
335function useBlockAtom<T>(blockId: string, name: string, makeFn: () => Atom<T>): Atom<T> {
336 const blockCache = getSingleBlockAtomCache(blockId);
337 let atom = blockCache.get(name);
338 if (atom == null) {
339 atom = makeFn();
340 blockCache.set(name, atom);
341 }
342 return atom as Atom<T>;
343}
344
345/**
346 * Safely read an atom value, returning null if the atom is null.

Callers 2

constructorMethod · 0.90

Calls 3

getSingleBlockAtomCacheFunction · 0.85
getMethod · 0.80
setMethod · 0.80

Tested by

no test coverage detected