@pond-ts/react API Reference
    Preparing search index...

    Function useLiveQuery

    • Build a derived live view once, subscribe, and return both the view and a throttled snapshot — combining useMemo + useSnapshot in one call.

      Typical dashboard code creates 5–10 derived views (filters, aggregations, rolling windows). Without this hook each one needs a manual useMemo for stability plus a separate useSnapshot for subscription. useLiveQuery bundles that into a single call whose return shape matches useLiveSeries:

      const [, rollingSnap] = useLiveQuery(
      () => live.rolling('1m', { cpu: 'avg' }),
      [live],
      { throttle: 200 },
      );

      const [highCpu, highCpuSnap] = useLiveQuery(
      () => live.filter((e) => e.get('cpu') > 0.7),
      [live],
      );

      Type Parameters

      Parameters

      • build: () => T

        Factory that creates the live view. Called once per deps change.

      • deps: readonly unknown[]

        React dependency array — when any dep changes, the view is rebuilt.

      • Optionaloptions: UseSnapshotOptions

        Snapshot throttle options (default 100 ms).

      Returns [T, TimeSeries<S> | null]

      [view, snapshot] — the stable view and its throttled TimeSeries.