reactive-values
Version:
Lightweight reactive value library with support for deep equality and computed values.
26 lines (25 loc) • 746 B
TypeScript
/**
* Interface representing a reactive value.
* @template T
*/
export interface ComputedValue<T> {
/**
* Gets the current value.
*/
(): T;
/**
* Registers a listener that reacts to value changes.
* @param {(value: T) => void} listener - The listener function.
* @returns {() => boolean} Function to remove the listener.
*/
effect: (listener: (value: T) => void) => (() => boolean);
}
/**
* Options for configuring reactive values.
* @property {boolean} [asyncEffect] - Whether to run effect listeners asynchronously.
* @property {boolean} [asyncUpdates] - Whether to apply updates asynchronously.
*/
export interface ComputedOptions {
asyncEffect?: boolean;
asyncUpdates?: boolean;
}