Enode — API Reference
    Preparing search index...
    • React binding for createSingleFlight: guards a tap handler against double-firing and exposes a busy flag for the in-flight window.

      Type Parameters

      • Args extends unknown[]

      Parameters

      • handler: (...args: Args) => unknown

        The guarded function; may be sync or async.

      • Optionaloptions: Pick<SingleFlightOptions, "lockoutMs">

        lockoutMs override for the trailing suppression window.

      Returns [run: (...args: Args) => void, busy: boolean]

      [run, busy] — the guarded runner and whether an async run is currently pending.

      While a previous invocation's promise is pending (plus a short trailing lockout after it settles), re-entrant calls are dropped — a second tap on a slow frame or during a network round-trip can't run the action twice. busy is true only while an async run is pending; pair it with the shared Button's busy prop for spinner/disabled feedback. The returned runner is referentially stable across renders (safe to list in effect deps) and always calls the latest handler. lockoutMs is captured when the component first runs the handler and stays fixed after that.

      const [startSession, starting] = useSingleFlight(async (stationIdx: number) => {
      await verifySlot();
      fillStation(stationIdx);
      });
      <Button busy={starting} onClick={() => startSession(0)}>{t("Start")}</Button>