Package: @effect/atom-react
Module: Hooks
Subscribes a callback to an atom in the current React registry for the component lifetime.
When to use
Use when a React component needs to run a callback for atom changes without reading the atom value during render.
Details
The subscription is installed in a React effect and cleaned up on unmount or
dependency change. When options.immediate is enabled, the callback receives
the current value when the effect subscribes.
See
useAtomValue for reading an atom value during render instead of running a callbackSignature
declare const useAtomSubscribe: <A>(atom: Atom.Atom<A>, f: (_: A) => void, options?: { readonly immediate?: boolean; }) => void
Since v4.0.0