• Create a keyed suspense cache.

    Type Parameters

    Parameters

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

        (Advanced) You can provide the backing cache object

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

    • cache: Storage

      Access to the backing cache.

      Remark

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

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

          Parameters

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

          Returns Value

          Remark

          This will not call the function again if it changes, only when the key changes! If you don't need to respond to different keys, you can use createSuspense instead.

Generated using TypeDoc