/** * Creates a reactive side-effect that runs immediately and re-runs whenever * its dependencies change. * * - Runs `fn` immediately on creation. * - Automatically tracks any atoms/stores read inside `fn` as dependencies. * - Re-runs `fn` whenever any dependency changes (scheduled via the effect scheduler). * - If `fn` returns a cleanup function, that cleanup runs before the next execution * and when the effect is disposed. * - Returns a `dispose` function — call it to stop the effect and run the final cleanup. * - `fn` is marked `__isEffect__ = true` so the reactive runner knows it supports cleanup. * - Must NOT be called inside a template function (restricted context guard applies * via `createReactiveRunner`). * * @param fn - The side-effect function to run. May return a cleanup function that * is called before the next run and on disposal. * @returns A `dispose` function that stops the effect and runs the final cleanup. * * @example * const count = atom(0); * * const stop = effect(() => { * console.log("count is", count()); // runs immediately, then on every change * return () => console.log("cleanup"); // runs before next execution * }); * * count.set(1); // logs "cleanup", then "count is 1" * stop(); // dispose — runs final cleanup */ export declare function effect(fn: () => (() => void) | undefined | void): () => void; //# sourceMappingURL=effect.d.ts.map