state-synchronizers
Version:
Deterministically update state based on other state
9 lines (8 loc) • 455 B
TypeScript
import { StateUpdater, StateSynchronizer } from './types';
/**
* Works only for plain JS objects and top-level properties.
*
* @param dependenciesKeys Names of properties of state. When any changes, `updater` will be run.
* @returns A state synchronizer that runs the updater whenever a dependency changes.
*/
export declare const createStateSynchronizer: <S>(updater: StateUpdater<S>, dependenciesKeys: (keyof S)[]) => StateSynchronizer<S>;