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

    Function useCurrent

    • Subscribe to a live source and return the current value of a reducer mapping, updated on a throttle. Equivalent to useSnapshot(src).tail(tail).reduce(mapping) but with one subscription, one memo, and narrow per-entry types inherited from TimeSeries.reduce.

      const current = useCurrent(live, { cpu: 'avg', host: 'unique' });
      // ^ { cpu: number | undefined;
      // host: ReadonlyArray<ScalarValue> | undefined }

      const recent = useCurrent(live, { cpu: 'p95' }, { tail: '30s' });

      Returns a stable-shape object while the source has no events (every mapped field is undefined), so destructuring on first render is safe.

      Reference stability: when a new event push leaves the reduce output structurally unchanged (same scalar values, same-length arrays with same elements), the previous result reference is returned unchanged. Downstream useMemo([value]) and useEffect([value]) only re-run when the value actually changes — no need for a manual .slice() or deep-compare equality helper at the call site.

      Type Parameters

      • S extends SeriesSchema
      • const Mapping extends Readonly<AggregateMapEntries<S>>

      Parameters

      Returns ReduceResult<S, Mapping>