UNPKG

fluidstate

Version:

Library for fine-grained reactivity state management

21 lines (20 loc) 1.01 kB
import { CreateComputedAtom } from "./reactive-primitive-types"; /** * Creates a computed reactive atom that derives its value from other reactive sources. * * This function wraps the reactive layer's `createComputedAtom` primitive, adding * handling of reactive remotes. * * The computed value is cached and only re-evaluated if its dependencies change, * provided it's being observed by a reaction. Otherwise, it behaves like a * regular getter, re-computing on each call. * * @param name - A descriptive name for the computed atom, useful for debugging. * @param calculate - The function that computes the value of the atom. It will * be re-run when its reactive dependencies change. * @param options - Optional configuration for the computed atom, such as * custom equality checks (`equals`) or lifecycle listeners (`onBecomeObservedListener`, * `onBecomeUnobservedListener`). * @returns A `ComputedAtom` instance. */ export declare const createComputedAtom: CreateComputedAtom;