import * as Exit from "effect/Exit"; import * as AsyncResult from "effect/unstable/reactivity/AsyncResult"; import * as Atom from "effect/unstable/reactivity/Atom"; import type * as AtomRef from "effect/unstable/reactivity/AtomRef"; import type { Accessor, ResourceOptions, ResourceReturn } from "solid-js"; /** * Seeds initial atom values in the current Solid atom registry. * * **When to use** * * Use to seed atom values from a Solid component after the current registry * already exists. * * **Details** * * For each atom in the current registry, this hook applies the first value * supplied through the hook. Later calls for the same atom in that registry are * ignored. * * @category hooks * @since 4.0.0 */ export declare const useAtomInitialValues: (initialValues: Iterable, any]>) => void; /** * Subscribes to an atom in the current Solid registry and returns its value as * a Solid accessor. * * @category hooks * @since 4.0.0 */ export declare const useAtomValue: { /** * Subscribes to an atom in the current Solid registry and returns its value as * a Solid accessor. * * @category hooks * @since 4.0.0 */ (atom: () => Atom.Atom): Accessor; /** * Subscribes to an atom in the current Solid registry and returns its value as * a Solid accessor. * * @category hooks * @since 4.0.0 */ (atom: () => Atom.Atom, f: (_: A) => B): Accessor; }; /** * Mounts an atom in the current Solid registry for the lifetime of the current * Solid computation. * * **When to use** * * Use to keep an atom mounted from a Solid owner without reading, writing, or * refreshing it. * * **Details** * * The hook uses the current `RegistryContext`, mounts inside a Solid * computation, and releases the mount through Solid cleanup when the * computation changes or the owner is disposed. * * @see {@link useAtomSet} for mounting a writable atom while returning a setter * @see {@link useAtomRefresh} for mounting an atom while returning a refresh callback * * @category hooks * @since 4.0.0 */ export declare const useAtomMount: (atom: () => Atom.Atom) => void; /** * Returns a setter for a writable atom without subscribing to its value. * * @category hooks * @since 4.0.0 */ export declare const useAtomSet: (atom: () => Atom.Writable, options?: { readonly mode?: ([R] extends [AsyncResult.AsyncResult] ? Mode : "value") | undefined; }) => "promise" extends Mode ? ((value: W) => Promise>) : "promiseExit" extends Mode ? ((value: W) => Promise, AsyncResult.AsyncResult.Failure>>) : ((value: W | ((value: R) => W)) => void); /** * Mounts an atom and returns a callback that refreshes the current atom. * * @category hooks * @since 4.0.0 */ export declare const useAtomRefresh: (atom: () => Atom.Atom) => () => void; /** * Returns a Solid accessor for a writable atom together with a setter for * updating it. * * **When to use** * * Use when a Solid component or computation needs both a reactive accessor for * a writable atom and a write function for that same atom. * * **Details** * * The setter accepts either a write value or an updater function. For * `AsyncResult` atoms, `promise` and `promiseExit` modes return promises for the * success value or full `Exit`. * * @see {@link useAtomValue} for subscribing to an atom without a setter * @see {@link useAtomSet} for updating a writable atom without subscribing to its value * * @category hooks * @since 4.0.0 */ export declare const useAtom: (atom: () => Atom.Writable, options?: { readonly mode?: ([R] extends [AsyncResult.AsyncResult] ? Mode : "value") | undefined; }) => readonly [value: Accessor, write: "promise" extends Mode ? ((value: W) => Promise>) : "promiseExit" extends Mode ? ((value: W) => Promise, AsyncResult.AsyncResult.Failure>>) : ((value: W | ((value: R) => W)) => void)]; /** * Subscribes a callback to an atom in the current Solid registry. * * @category hooks * @since 4.0.0 */ export declare const useAtomSubscribe: (atom: () => Atom.Atom, f: (_: A) => void, options?: { readonly immediate?: boolean; }) => void; /** * Converts an `AsyncResult` atom into a Solid resource. * * @category hooks * @since 4.0.0 */ export declare const useAtomResource: (atom: () => Atom.Atom>, options?: ResourceOptions & { readonly suspendOnWaiting?: boolean | undefined; }) => ResourceReturn; /** * Subscribes to an atom ref and returns its value as a Solid accessor. * * **When to use** * * Use when a Solid component or computation should render from an * `AtomRef.ReadonlyRef` directly instead of reading an atom through the current * registry. * * **Details** * * The hook accepts a thunk for the ref, reads `ref().value`, subscribes with * `ref.subscribe`, and releases the subscription through Solid cleanup when * the selected ref changes or the owner is disposed. * * @see {@link useAtomValue} for reading an `Atom` from the current registry * @see {@link useAtomRefPropValue} for reading a property ref value * * @category hooks * @since 4.0.0 */ export declare const useAtomRef: (ref: () => AtomRef.ReadonlyRef) => Accessor; /** * Returns a Solid accessor for a property ref derived from an atom ref. * * **When to use** * * Use to derive an `AtomRef` for one property of an object-shaped atom ref in a * Solid computation. * * **Details** * * The returned accessor memoizes `ref().prop(prop)`, updating when the source * ref thunk produces a different ref. * * **Gotchas** * * The `prop` argument is captured as a plain value. Recreate the hook call when * the property key should change. * * @see {@link useAtomRef} for subscribing to an atom ref value * @see {@link useAtomRefPropValue} for subscribing directly to a property value * * @category hooks * @since 4.0.0 */ export declare const useAtomRefProp: (ref: () => AtomRef.AtomRef, prop: K) => Accessor>; /** * Returns a Solid accessor for the value of a property ref derived from an atom * ref. * * **When to use** * * Use when a Solid component or computation needs the value of one property * from an object-shaped `AtomRef` without keeping the intermediate property ref. * * **Details** * * The hook composes `useAtomRefProp(ref, prop)` with `useAtomRef`, returning a * Solid accessor for the selected property value. * * **Gotchas** * * The `prop` argument is captured as a plain value. Recreate the hook call when * the property key should change. * * @see {@link useAtomRef} for subscribing to a whole atom ref value * @see {@link useAtomRefProp} for returning the property ref directly * * @category hooks * @since 4.0.0 */ export declare const useAtomRefPropValue: (ref: () => AtomRef.AtomRef, prop: K) => Accessor; //# sourceMappingURL=Hooks.d.ts.map