abon
Version:
Flexible state management for React 🚀
22 lines (21 loc) • 1.14 kB
TypeScript
import { Abon } from "./abon";
import { AbonSet } from "./abon-set";
import { ReadonlyAbon } from "./readonly-abon";
import { ChangeListener, UnsubscribeFn, ValueHandler } from "./types";
/** Inherits a value from children if the current value is undefined. */
export declare class ReadonlyAbonInheritedUp<T> implements ReadonlyAbon<T> {
protected readonly children: AbonSet<Pick<ReadonlyAbon<T | undefined>, "subscribe" | "current">>;
protected readonly value: Abon<T>;
protected readonly childValue: ReadonlyAbon<T>;
constructor();
subscribe(listener: ChangeListener<T>): UnsubscribeFn;
handle(handler: ValueHandler<T>): UnsubscribeFn;
addChild<AT extends Pick<ReadonlyAbon<T | undefined>, "subscribe" | "current">>(abon: AT): AT;
addChild(abon: Abon<T>): Abon<T>;
addChild(): Abon<T | undefined>;
removeChild(child: Pick<ReadonlyAbon<T | undefined>, "subscribe" | "current">): void;
use(): this;
useSubscription(listener: ChangeListener<T>, deps?: readonly any[]): void;
useHandler(handler: ValueHandler<T>, deps?: readonly any[]): void;
get current(): T;
}