Utility class for caching stable data

Type Parameters

  • T

Constructors

  • Type Parameters

    • T

    Parameters

    • refreshData: ((params?) => Promise<T>)

      function that refresh and return the data

        • (params?): Promise<T>
        • Parameters

          • Optional params: any

          Returns Promise<T>

    • Optional cacheMaxAge: number

      time in millisecond to expire cache

    Returns CachedValue<T>

Properties

cacheMaxAge: number
cacheTimestamp: undefined | Date
cachedValue: undefined | T
refreshData: ((params?) => Promise<T>)

Type declaration

    • (params?): Promise<T>
    • Parameters

      • Optional params: any

      Returns Promise<T>

refreshPromise: null | Promise<T> = null

Methods

  • Returns cached data if valid or request fresh data if cache is invalid

    Parameters

    • Optional params: any

      use this params to request data if cache is expired

    Returns Promise<T>

  • Private

    Validates if internal cache is valid or expired

    Returns boolean

Generated using TypeDoc