(blockId: string, name: string, makeFn: () => Atom<T>)
| 333 | } |
| 334 | |
| 335 | function 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. |
no test coverage detected