import { Atom } from "./types.mjs"; //#region ../@mongez/atom/src/derive.d.ts /** * The reader passed to a derive compute function. Calling `get(atom)` * registers that atom as a dependency and returns its current value. */ type DeriveGetter = (atom: Atom) => V; type DeriveOptions = { /** * Skip the global `atoms` registry. Used by `AtomStore` clones — most * consumers should leave this alone. * @default true */ register?: boolean; }; /** * Create a derived atom. * * The compute function runs once eagerly on creation to seed the initial * value and to discover dependencies. After that, it re-runs every time * any tracked dependency changes. * * Conditional reads work: an `if` branch inside the compute function * that reads a different atom on a later run picks up the new dep and * drops the old one. This handles the "dynamic dependency graph" case * (e.g. `if (get(currentRoute) === "users") return get(usersAtom)`). * * Calling `update`, `silentUpdate`, `change`, `merge` directly on the * returned atom works but is discouraged — the next dependency change * will overwrite anything you wrote. Use a regular atom if you need * writable state. */ declare function derive(key: string, compute: (get: DeriveGetter) => T, options?: DeriveOptions): Atom; //#endregion export { DeriveGetter, DeriveOptions, derive }; //# sourceMappingURL=derive.d.mts.map