/** Compares an old and new value; return true to suppress the update. */ export type Equals = (a: T, b: T) => boolean; export interface Signal { /** Read the current value and subscribe the enclosing effect/computed. */ (): T; /** Write a new value. */ (value: T): T; /** Write a new value. */ set(value: T): T; /** Read without subscribing. */ peek(): T; /** Write a value derived from the current one. */ update(fn: (current: T) => T): T; } export interface Computed { /** Read the current value and subscribe the enclosing effect/computed. */ (): T; /** Read without subscribing. */ peek(): T; } /** Cleanup run before the next execution and once on dispose. */ export type Cleanup = () => void; /** Stops an effect (or a scope) and runs its cleanups. */ export type Dispose = () => void; export function signal(value: T, equals?: Equals): Signal; export function signal(): Signal; export function computed(fn: () => T, equals?: Equals): Computed; export function effect(fn: () => void | Cleanup): Dispose; export function batch(fn: () => T): T; export function untrack(fn: () => T): T; /** True while a subscriber (an effect or a computed) is collecting * dependencies — reads made now will subscribe it. */ export function tracking(): boolean; export function root(fn: () => void): Dispose; export function onCleanup(fn: Cleanup): Cleanup; export function flush(): void;