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

Function useAtomSet

packages/atom/solid/src/Hooks.ts:153–173  ·  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

151 * @since 4.0.0
152 */
153export const useAtomSet = <
154 R,
155 W,
156 Mode extends "value" | "promise" | "promiseExit" = never
157>(
158 atom: () => Atom.Writable<R, W>,
159 options?: {
160 readonly mode?: ([R] extends [AsyncResult.AsyncResult<any, any>] ? Mode : "value") | undefined
161 }
162): "promise" extends Mode ? (
163 (value: W) => Promise<AsyncResult.AsyncResult.Success<R>>
164 ) :
165 "promiseExit" extends Mode ? (
166 (value: W) => Promise<Exit.Exit<AsyncResult.AsyncResult.Success<R>, AsyncResult.AsyncResult.Failure<R>>>
167 ) :
168 ((value: W | ((value: R) => W)) => void) =>
169{
170 const registry = useContext(RegistryContext)
171 mountAtom(registry, atom)
172 return setAtom(registry, atom, options)
173}
174
175/**
176 * Mounts an atom and returns a callback that refreshes the current atom.

Callers

nothing calls this directly

Calls 2

mountAtomFunction · 0.70
setAtomFunction · 0.70

Tested by

no test coverage detected