cockpit-plugin-base-react - v1.1.1
    Preparing search index...

    Function usePollingFetch

    • Fetches data on mount and then polls at a fixed interval.

      The initial load sets loading = true; subsequent background polls and manual refresh() calls update data silently without a loading flash.

      Type Parameters

      • T

      Parameters

      • fetcher: () => Promise<T>

        Async function that returns the data. Wrap in useCallback to avoid restarting the interval on every render.

      • initial: T

        Value used for data before the first fetch resolves.

      • intervalMs: number

        Polling interval in milliseconds.

      • paused: boolean = false

        When true, pauses background polling (does not cancel an in-flight request).

      • options: PollingFetchOptions = {}

        Optional config (e.g. errorThreshold).

      Returns PollingFetchResult<T>