MCPcopy Create free account
hub / github.com/Effect-TS/effect / useAtomInitialValues

Function useAtomInitialValues

packages/atom/solid/src/Hooks.ts:39–52  ·  view source on GitHub ↗
(initialValues: Iterable<readonly [Atom.Atom<any>, any]>)

Source from the content-addressed store, hash-verified

37 * @since 4.0.0
38 */
39export const useAtomInitialValues = (initialValues: Iterable<readonly [Atom.Atom<any>, any]>): void => {
40 const registry = useContext(RegistryContext)
41 let set = initialValuesSet.get(registry)
42 if (set === undefined) {
43 set = new WeakSet()
44 initialValuesSet.set(registry, set)
45 }
46 for (const [atom, value] of initialValues) {
47 if (!set.has(atom)) {
48 set.add(atom)
49 ;(registry as any).ensureNode(atom).setValue(value)
50 }
51 }
52}
53
54/**
55 * Subscribes to an atom in the current Solid registry and returns its value as

Callers 1

childrenFunction · 0.50

Calls 6

ensureNodeMethod · 0.80
getMethod · 0.65
setMethod · 0.65
addMethod · 0.65
hasMethod · 0.45
setValueMethod · 0.45

Tested by 1

childrenFunction · 0.40