UNPKG

567 BTypeScriptView Raw
1export declare type UpdateFn<S> = (state: S) => S;
2export declare type Subscriber<S> = (state: S) => void;
3export declare type Cb<S> = (newV: S, oldV: S, source?: unknown) => void;
4export declare type Unsubscribe = () => void;
5export interface ITangleContext<S> {
6 stateOf(key: KeyOf<S>): S[KeyOf<S>];
7 subscribe(key: KeyOf<S>, cb: Cb<S[KeyOf<S>]>): Unsubscribe;
8 /**
9 * Update the given
10 * @param key
11 * @param source
12 */
13 update<C = unknown>(key: KeyOf<S>, newV: S[KeyOf<S>], caller?: C): void;
14}
15export declare type KeyOf<S> = keyof S;