Function useCache

  • This function is a custom hook that caches the result of an asynchronous function and returns it if it exists in the cache. If not, it calls the function and caches the result for future calls. It also sets a stale time after which the result is considered outdated and will be refetched on the next call. The hook returns a boolean indicating whether the result is stale or not.

    Type Parameters

    • AF extends AsyncFunc

    Parameters

    • injectableFn: AF

      the asynchronous function to memoize

    • cacheProvider: CacheProvider<R<AF>, any[]>

      the cache provider for the function results

    • staleTime: number = 0

      the time in milliseconds after which the cached result is considered stale

    Returns boolean

    a boolean indicating whether the cached result is stale or not

Generated using TypeDoc