You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -957,6 +985,107 @@ A promise resolving to an object with the below keys:
957
985
| `error?` | `Object` | An object containing an error if present. *Defaults to an `Error` object with a thrown `fetch` error. This is not for API errors (e.g. Status 500 or 400). See `data` for that* |
958
986
| `run` | `async () => {}` | A function for bypassing the cache and firing an API call. Can be awaited. |
959
987
988
+
### streamFetchye
989
+
990
+
A helper to enable streaming for server side Fetchye API calls. The first parameter is a [`oneFetchye`](https://github.com/americanexpress/fetchye?tab=readme-ov-file#oneFetchye) thunk.
991
+
992
+
Note: The key and options are used to compute the cache key and must match the values passed to `useStreamedFetchye` for a successful cache hit. When `options.throwOnError` is enabled, the function will throw an error for unsuccessful requests which will bubble up to the nearest error boundary. When disabled, the success status of the request must be manually checked.
| `thunk` | `Function` | `true` | A fetchye Redux thunk that will be called with the key, options, and fetcher. |
1013
+
| `key` | `String` | `true` | A string that factors into cache key creation. *Defaults to URL compatible string*. |
1014
+
| `options` | `Object<ES6FetchOptions & CustomFetchOptions>` | `false` | Options to pass through to [ES6 Fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). See **Options** table for the CustomFetchOptions which do not get passed through to [ES6 Fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). |
1015
+
| `fetcher` | `async (fetchClient:Fetch, key:String, options:Options) => ({ payload:Object, error?:Object })` | `false` | The async function that calls `fetchClient` by key and options. Returns a `payload` with outcome of `fetchClient` and an optional `error` object. |
| `throwOnError` | `boolean` | `false` | This option overrides the default fetchye behavior of catching failed requests. When enabled, unsuccessful responses will throw an error containing the payload of the request. This is intended to be used within a suspense boundary.
1022
+
1023
+
**`streamFetchye` Returns**
1024
+
1025
+
A promise resolving to the value of the thunk.
1026
+
1027
+
### useStreamedFetchye
1028
+
1029
+
A React hook used to read streamed data from the server. It will return the raw promise that the user can then parse manually. If there is no existing data from the server, a request will be performed on the client.
1030
+
1031
+
The key and options are used to compute the cache key and must match the values passed to `streamedFetchye` for a successful cache hit. When `options.throwOnError` is enabled, the hook will throw an error for unsuccessful responses which will bubble up to the nearest error boundary. When disabled, the success status of the request must be manually checked.
1032
+
1033
+
Note: The hook is intended to be used within a suspense boundary.
| `key` | `String` | `true` | A string that factors into cache key creation. *Defaults to URL compatible string*. |
1075
+
| `options` | `Object<ES6FetchOptions & CustomFetchOptions>` | `false` | Options to pass through to [ES6 Fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). See **Options** table for the CustomFetchOptions which do not get passed through to [ES6 Fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). |
1076
+
| `fetcher` | `async (fetchClient:Fetch, key:String, options:Options) => ({ payload:Object, error?:Object })` | `false` | The async function that calls `fetchClient` by key and options. Returns a `payload` with outcome of `fetchClient` and an optional `error` object. |
| `throwOnError` | `boolean` | `false` | This option overrides the default fetchye behavior of catching failed requests. When enabled, unsuccessful responses will throw an error containing the payload of the request. This is intended to be used within a suspense boundary.
1083
+
1084
+
1085
+
**`useStreamedFetchye` Returns**
1086
+
1087
+
A promise resolving to the streamed or local promise.
1088
+
960
1089
### Providers
961
1090
962
1091
A Provider creates a React Context to connect all the `useFetchye` Hooks into a centrally stored cache.
0 commit comments