• Create a suspense cache for a single value.

    Type Parameters

    Parameters

    • options: {
          storage?: Storage;
      } = {}
      • Optional storage?: Storage

        (Advanced) You can provide the backing cache object

        By default it uses an internal implementation based on an internal variable, but you can provide your own implementation

    Returns {
        cache: Storage;
        suspend: ((fn) => Value);
    }

    • cache: Storage

      Access to the backing cache.

      Remark

      Useful for doing cache.set(null), and force a re-fetch.

    • suspend: ((fn) => Value)
        • (fn): Value
        • Suspend your tree while the async function resolves, and return its promise's value

          Parameters

          • fn: (() => Promise<Value>)
              • (): Promise<Value>
              • Returns Promise<Value>

          Returns Value

          Remark

          This will not call the function again if it changes! If you need to respond to different arguments, you can use createKeyedSuspense instead.

Generated using TypeDoc