state-synchronizers
Version:
Deterministically update state based on other state
14 lines (13 loc) • 486 B
TypeScript
export declare type StateUpdater<S> = (state: S) => S;
export declare type StateSynchronizer<S> = (state: S, previousState: Readonly<S>) => S;
export interface ComposableStateSynchronizer<S, K extends keyof any = keyof S> {
/**
* The name of a piece of state that the synchronizer updates
*/
stateKey: K;
/**
* Names of pieces of state that the synchronizer depends on
*/
dependenciesKeys: K[];
synchronizer: StateSynchronizer<S>;
}