Skip to content
GitHub

@effectify/solid-effect-atom

Subscribes to an atom and returns a tuple of [accessor, setter].

function useAtom<R, W>(
  atom: Atom.Writable<R, W>,
): [Accessor<R>, (value: W) => void]

Subscribes to an atom and returns its value as an accessor.

function useAtomValue<A>(atom: Atom.Atom<A>): Accessor<A>
function useAtomValue<A, B>(atom: Atom.Atom<A>, f: (a: A) => B): Accessor<B>

Returns a setter function for the atom without subscribing to its value.

function useAtomSet<R, W>(atom: Atom.Writable<R, W>): (value: W) => void

Subscribes to changes in an atom’s value.

function useAtomSubscribe<A>(
  atom: Atom.Atom<A>,
  f: (value: A) => void,
  options?: { immediate?: boolean },
): void

Mounts an atom in the registry without subscribing to its value. This is useful for keeping an atom alive.

function useAtomMount<A>(atom: Atom.Atom<A>): void

Returns a function that forces an atom to refresh its value.

function useAtomRefresh<A>(atom: Atom.Atom<A>): () => void

Sets initial values for atoms in the current registry. Useful for SSR or initialization.

function useAtomInitialValues(
  initialValues: Iterable<[Atom.Atom<any>, any]>,
): void

Subscribes to an AtomRef and returns its value as an accessor.

function useAtomRef<A>(ref: AtomRef.ReadonlyRef<A>): Accessor<A>

Creates a derived AtomRef for a specific property of an object stored in an AtomRef.

function useAtomRefProp<A, K extends keyof A>(
  ref: AtomRef.AtomRef<A>,
  prop: K,
): AtomRef.AtomRef<A[K]>

Subscribes to a specific property of an object stored in an AtomRef.

function useAtomRefPropValue<A, K extends keyof A>(
  ref: AtomRef.AtomRef<A>,
  prop: K,
): Accessor<A[K]>

Provides the AtomRegistry context to the component tree. This is required for all atom hooks to work.

function RegistryProvider(props: {
  children?: JSX.Element
  initialValues?: Iterable<[Atom.Atom<any>, any]>
  scheduleTask?: (f: () => void) => () => void
  timeoutResolution?: number
  defaultIdleTTL?: number
}): JSX.Element