abon
Version:
Flexible state management for React 🚀
18 lines (17 loc) • 1.2 kB
TypeScript
import { Abon } from "./abon";
import { ReadonlyAbon } from "./readonly-abon";
import { ComposedSubscriberFlex, UnsubscribeFn } from "./types";
/** Subscribe to, retrieve, and update a value. Equality checks are strict. */
export declare class AbonStrict<T> extends ReadonlyAbon<T> implements Abon<T> {
current: T;
constructor(initial?: T);
set(value: T): this;
notify(): void;
static use<T>(initial?: () => T, deps?: readonly any[]): AbonStrict<T>;
static useRef<T>(initial?: () => T, deps?: readonly any[]): AbonStrict<T>;
/** Creates an `Abon` based on a value that should be updated given a selection of subscriptions. */
static from<T>(getValue: () => T, listen: ComposedSubscriberFlex, setUnsubscribe?: (unsubscribe: UnsubscribeFn) => void): ReadonlyAbon<T>;
static from<T>(getValue: () => T, listen: ComposedSubscriberFlex, unsubscribeFns?: Set<Function>): ReadonlyAbon<T>;
static from<T>(getValue: () => T, listen: ComposedSubscriberFlex, unsubscribeFns?: Set<Function>): ReadonlyAbon<T>;
static useFrom<T>(listen: (listener: (value: T) => void) => UnsubscribeFn, initial?: () => T, deps?: readonly any[]): ReadonlyAbon<T>;
}