| 37 | * @since 4.0.0 |
| 38 | */ |
| 39 | export 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 |