UNPKG

abon

Version:

Flexible state management for React 🚀

17 lines (16 loc) • 1.09 kB
import { ReadonlyAbon } from "./readonly-abon"; import { ComposedSubscriberFlex, UnsubscribeFn } from "./types"; /** Subscribe to, retrieve, and update a value. */ export declare class Abon<T> extends ReadonlyAbon<T> { current: T; constructor(initial?: T); set(value: T): this; notify(): void; static use<T>(initial?: () => T, deps?: readonly any[]): Abon<T>; static useRef<T>(initial?: () => T, deps?: readonly any[]): Abon<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[]): Abon<T>; }