@zedux/atoms
Version:
A Molecular State Engine for React
18 lines (17 loc) • 804 B
TypeScript
import { EffectCallback, InjectorDeps } from '../types/index';
/**
* Runs a deferred side effect. This is just like React's `useEffect`. When
* `deps` change on a subsequent reevaluation, the previous effect will be
* cleaned up and the effect will rerun.
*
* Return a cleanup function to clean up resources when the effect reruns or the
* current atom instance is destroyed.
*
* Unlike `useEffect`, you can return a promise from `injectEffect` (e.g. by
* passing an async function). This is only for convenience in cases where you
* don't have anything to cleanup, as you'll be unable to clean up resources if
* you return a promise.
*/
export declare const injectEffect: (effect: EffectCallback, deps?: InjectorDeps, config?: {
synchronous?: boolean | undefined;
} | undefined) => any;