//#region src/util/use-slow-loading.d.ts /** * How long something must be loading before an indicator appears. Loads that finish inside this * window never render one at all. */ declare const LOADING_DELAY_MS = 300; /** * Once an indicator is on screen, how long it stays there even if the wait has already ended. * Applies only to waits that already crossed {@link LOADING_DELAY_MS} — its whole job is to stop a * just-shown indicator vanishing a frame later. */ declare const LOADING_MIN_DURATION_MS = 300; interface SlowLoadingOptions { /** Don't surface before the wait has lasted this long. Defaults to {@link LOADING_DELAY_MS}. */ after?: number; /** * Once surfaced, stay up at least this long. Defaults to {@link LOADING_MIN_DURATION_MS}. */ minDuration?: number; } /** * Whether a wait has gone on long enough to be worth telling the user about. * * Loading UI flashes on fast responses: a request that resolves in 60 ms produces a 60 ms skeleton — * long enough to see, too short to read, and it happens on every navigation. This is the standard * two-part fix, in one place: * * - **A threshold.** A wait shorter than `after` never surfaces at all. * - **A floor.** Once it has surfaced, it stays for `minDuration`. * * Both halves are needed. A threshold alone turns a 320 ms wait into a 20 ms flash, which is worse * than either extreme. * * **This returns a third state, and a caller that renders two will be wrong.** The point of the * threshold is that there is a window where the wait is real but not yet worth mentioning — so * "not slow" does not mean "ready", and the data may still be missing: * * ```tsx * const slow = useSlowLoading(!list.loaded); * * if (slow) return ; * if (!list.loaded) return null; // loading, but too early to say so * return ; * ``` * * Both branch orders matter: * * - `slow` is tested **first** because the floor outlives the wait. Once surfaced, this stays true * for `minDuration` even after the value has landed, and testing the value first would swap the * content in immediately — which is the flash the floor exists to prevent. * - The `null` branch is what makes the threshold real. Drop it and the first `after` milliseconds * render the content branch with nothing to put in it. * * | value | `slow` | render | * | -------- | ------ | ----------------------------------- | * | missing | false | nothing — inside the threshold | * | missing | true | the skeleton | * | present | true | the skeleton, held by the floor | * | present | false | the content | * * `LazyObserver` and `` are this same sequence, already wired up; reach for the hook * where a component renders its own skeleton. * * Plain boolean in, plain boolean out, so it works the same inside an `observer()` and outside one — * pass it anything, including a value read from a lazy or a store. * * `after: 0` surfaces immediately and `minDuration: 0` hides immediately, which together collapse * the third state away: with both at zero, `slow` and the wait are the same flag and two branches * are enough. */ declare function useSlowLoading(active: boolean, options?: SlowLoadingOptions): boolean; //#endregion export { useSlowLoading as i, LOADING_MIN_DURATION_MS as n, SlowLoadingOptions as r, LOADING_DELAY_MS as t }; //# sourceMappingURL=use-slow-loading-D5q4M47N.d.mts.map