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

Function useAtomSet

packages/atom/react/src/Hooks.ts:209–229  ·  view source on GitHub ↗
(
  atom: Atom.Writable<R, W>,
  options?: {
    readonly mode?: ([R] extends [AsyncResult.AsyncResult<any, any>] ? Mode : "value") | undefined
  }
)

Source from the content-addressed store, hash-verified

207 * @since 4.0.0
208 */
209export const useAtomSet = <
210 R,
211 W,
212 Mode extends "value" | "promise" | "promiseExit" = never
213>(
214 atom: Atom.Writable<R, W>,
215 options?: {
216 readonly mode?: ([R] extends [AsyncResult.AsyncResult<any, any>] ? Mode : "value") | undefined
217 }
218): "promise" extends Mode ? (
219 (value: W) => Promise<AsyncResult.AsyncResult.Success<R>>
220 ) :
221 "promiseExit" extends Mode ? (
222 (value: W) => Promise<Exit.Exit<AsyncResult.AsyncResult.Success<R>, AsyncResult.AsyncResult.Failure<R>>>
223 ) :
224 ((value: W | ((value: R) => W)) => void) =>
225{
226 const registry = React.useContext(RegistryContext)
227 mountAtom(registry, atom)
228 return setAtom(registry, atom, options)
229}
230
231/**
232 * Mounts an atom and returns a callback that refreshes it in the current React

Callers

nothing calls this directly

Calls 2

mountAtomFunction · 0.70
setAtomFunction · 0.70

Tested by

no test coverage detected