UNPKG

react-tangle

Version:

A Simple State Management Library in React

16 lines (15 loc) 592 B
export declare type UpdateFn<S> = (state: S) => S; export declare type Subscriber<S> = (state: S) => void; export declare type Cb<S = unknown> = (newV: S, oldV: S, source?: unknown) => void; export declare type Unsubscribe = () => void; export interface ITangleContext<S> { stateOf<K extends keyof S>(key: K): S[K]; subscribe<K extends keyof S>(key: K, cb: Cb<S[K]>): Unsubscribe; /** * Update the given * @param key * @param source */ update<K extends keyof S, C = unknown>(key: K, newV: S[K], caller?: C): void; } export declare type KeyOf<S> = keyof S;