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

Function useAtomSubscribe

packages/atom/solid/src/Hooks.ts:237–246  ·  view source on GitHub ↗
(
  atom: () => Atom.Atom<A>,
  f: (_: A) => void,
  options?: { readonly immediate?: boolean }
)

Source from the content-addressed store, hash-verified

235 * @since 4.0.0
236 */
237export const useAtomSubscribe = <A>(
238 atom: () => Atom.Atom<A>,
239 f: (_: A) => void,
240 options?: { readonly immediate?: boolean }
241): void => {
242 const registry = useContext(RegistryContext)
243 createEffect(() => {
244 onCleanup(registry.subscribe(atom(), f, options))
245 })
246}
247
248/**
249 * Converts an `AsyncResult` atom into a Solid resource.

Callers

nothing calls this directly

Calls 1

subscribeMethod · 0.65

Tested by

no test coverage detected