g2o-reactive
Version:
Wrapper around signal-polyfill to support different module formats
41 lines (34 loc) • 1.11 kB
TypeScript
type Equals<T> = (a: T, b: T) => boolean;
interface Readable<T> {
get(): T;
}
interface Writable<T> {
set(newValue: T): void;
}
interface State<T> extends Readable<T>, Writable<T> {
}
declare function computed<T>(computation: () => T, options?: {
equals?: Equals<T>;
}): Readable<T>;
/**
* An object should be Disposable if its lifetime is bounded by the holder.
* Such objects are normally created by the holding object.
*/
interface Disposable {
dispose(): void;
}
declare function effect(callback: () => unknown): Disposable;
/**
* Creates a signal using the Polyfill naming convention. Alias for {@link signal} function.
*/
declare function state<T>(initialValue: T, options?: {
equals?: Equals<T>;
}): State<T>;
/**
* Creates a signal using the Angular naming convention. Alias for {@link state} function.
*/
declare function signal<T>(initialValue: T, options?: {
equals?: Equals<T>;
}): State<T>;
declare function untrack<T>(cb: () => T): T;
export { type Disposable, type Equals, type Readable, type State, type Writable, computed, effect, signal, state, untrack };