Notes/static/js/lib/signals/signals-core.d.ts
2023-06-15 07:24:23 +02:00

18 lines
605 B
TypeScript

declare function batch<T>(callback: () => T): T;
declare class Signal<T = any> {
constructor(value?: T);
subscribe(fn: (value: T) => void): () => void;
valueOf(): T;
toString(): string;
peek(): T;
get value(): T;
set value(value: T);
}
declare function signal<T>(value: T): Signal<T>;
interface ReadonlySignal<T = any> extends Signal<T> {
readonly value: T;
}
declare function computed<T>(compute: () => T): ReadonlySignal<T>;
declare function effect(compute: () => unknown): () => void;
export { signal, computed, effect, batch, Signal, ReadonlySignal };