Function createFetchHandler

Create cached fetch handler for passed data type

Store using for data types, which change infrequently. For example, app infomation from getMe method. For method calls more often than the passed update period, returned data from cache without real request to backend API

Returned update data function receive isForce boolean parameter, if it true, for this method call function makes real request to backend API

  • Type Parameters

    • T

      One of library methods return data type

    Parameters

    • transport: Transport

      Transport class instance

    • method: ApiMethod

      Backend API method, data type related

    • castFn: ((value: any) => T)

      Convert backend API result to inner library method result type function

        • (value): T
        • Parameters

          • value: any

          Returns T

    • updatePeriod: number

      Updatin data from backend API period

    Returns ((isForce?: boolean) => Promise<T>)

    Update data type function

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

        • OptionalisForce: boolean

        Returns Promise<T>