MCPcopy Create free account
hub / github.com/effect-app/libs / trackByKeys

Function trackByKeys

packages/vue/src/atomQuery.ts:62–76  ·  view source on GitHub ↗
(keys: ReadonlyArray<ReadonlyArray<unknown>>)

Source from the content-addressed store, hash-verified

60// "active"). Idle cache entries refetch on the next mount.
61const keyAtoms = new Map<number, Set<Atom.Atom<AsyncResult.AsyncResult<any, any>>>>()
62
63const trackByKeys =
64 (keys: ReadonlyArray<ReadonlyArray<unknown>>) =>
65 <A, E>(atom: Atom.Atom<AsyncResult.AsyncResult<A, E>>): Atom.Atom<AsyncResult.AsyncResult<A, E>> =>
66 Atom.transform(atom, (get) => {
67 for (const key of keys) {
68 const h = Hash.hash(key)
69 let set = keyAtoms.get(h)
70 if (!set) keyAtoms.set(h, set = new Set())
71 set.add(atom)
72 get.addFinalizer(() => {
73 set.delete(atom)
74 if (set.size === 0) keyAtoms.delete(h)
75 })
76 }
77 return get(atom)
78 }, { initialValueTarget: atom })
79

Callers 2

trackWritableByKeysFunction · 0.85
buildQueryFamilyFunction · 0.85

Calls 6

addFinalizerMethod · 0.80
getFunction · 0.70
transformMethod · 0.65
getMethod · 0.65
setMethod · 0.65
addMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…