@expofp/floorplan
Version:
Interactive floor plan library for expos and events
35 lines • 2.41 kB
TypeScript
import { IAutorunOptions, IReactionOptions, IReactionPublic } from 'mobx';
import { DependencyList, EffectCallback } from 'react';
export declare function useAutorun(view: (r: IReactionPublic) => any, opts?: IAutorunOptions): void;
export declare function useReaction<T>(expression: (r: IReactionPublic) => T, effect: (arg: T, r: IReactionPublic) => void, opts?: IReactionOptions, deps?: DependencyList): void;
/**
* Watches a **one-shot store command** — a flag the store sets and the consumer clears — from the
* first moment the consumer can actually act on one.
*
* Both halves of that matter, and a plain `reaction` gets both wrong for these flags:
*
* - It cannot see a command set *before* it subscribed. A reaction adopts whatever the expression
* reads at subscribe time as its baseline, so such a command is never delivered and, since
* nothing re-sets it, sits unhandled forever.
* - It would act on one set *too early*. The scene fits its space to the canvas in an effect of its
* own, and React runs a parent's effects after its children's, so a consumer mounted under the
* scene has no usable camera until the next frame. A command spent there is consumed and lost.
*
* Both windows are real, and the plan opens them itself: it reports `ready` from the same
* synchronous block that hands React the scene, so `<MapCamera>` mounts a commit after a host can
* first call in, and its camera is only fitted the frame after that. A host that selects a booth on
* `ready` lands in one window or the other depending on how loaded the machine is — the booth
* highlighted, and the camera never moved.
*
* So the whole subscription waits for the end of the mounting commit, and drains whatever has piled
* up by then.
* @param read - Reads the command flag.
* @param handle - Acts on it and clears it. Also called with the flag's cleared value, which every
* handler already guards against — that is what makes each command land exactly once.
* @returns Disposes the watch.
*/
export declare function watchOneShot<T>(read: () => T, handle: (value: T) => void): () => void;
/** {@link watchOneShot}, held for as long as the component is mounted. */
export declare function useOneShotReaction<T>(read: () => T, handle: (value: T) => void, deps?: DependencyList): void;
export declare function useInit(effect: EffectCallback): void;
//# sourceMappingURL=mobx.d.ts.map