onReStateChange

This method is like an useEffect hook, but it is called when the state changes and lives outside of react. This method include an key dependency array, which is the state keys that you want to watch.

//mutedState.ts
import { createReState, onReStateChange } from '@raulpesilva/re-state';
export type Muted = boolean;
export const key = 'muted';
export const useMuted = createReState<Muted>(key, true);
onReStateChange(() => {
// do something
}, [key]);
type onReStateChange = (callback: FnVoid, dependencies: UniqueKey[]) => void;