wana
Version:
Easy observable state for React
40 lines (34 loc) • 1.49 kB
TypeScript
export { Derived, Watcher, isDerived, no, noto, o, watch, when } from './shared/c7f3bced';
import { ObserverTarget, Auto, Change, AutoObserver } from './shared/ed456245';
export { $$, $O, $T, Auto, AutoConfig, Change, ChangeObserver, Observable, ObservedSlot, Observer, ObserverTarget, auto, shallowChanges } from './shared/ed456245';
declare type OnRender = (auto: Auto, depth: number, component: React.FunctionComponent<any>) => void;
declare type Globals = {
/** Notify the current observer. */
observe: ((target: ObserverTarget, key: any) => void) | null;
/** The `Auto` object for the current `withAuto` component being rendered. */
auto: Auto | null;
/** For debugging re-renders. Only called in development. */
onRender: OnRender | null;
/** For spying on every change event. */
onChange: ((change: Change) => void) | null;
};
declare const globals: Globals;
/**
* Flush the queue of delayed reactions.
*
* Returns `true` if the queue wasn't flushed entirely.
*
* Useful when testing `wana`-integrated components/hooks.
*/
declare function flushSync(): boolean;
interface Props {
observer?: AutoObserver;
mounted?: boolean;
}
/**
* Call the returned function to set the "mounting state" for the
* given `Auto` object. Observation is postponed until mounted.
*/
declare function mountAuto(auto: Auto): (props: Props) => void;
declare const ObjectTraps: ProxyHandler<object>;
export { ObjectTraps, flushSync, globals, mountAuto };