Closed msutkowski closed 3 years ago
This pull request is automatically built and testable in CodeSandbox.
To see build info of the built libraries, click here or the icon next to each commit SHA.
Latest deployment of this branch, based on commit 133cd4580ff8371965b3c11fd0430406b444b835:
Sandbox | Source |
---|---|
React | Configuration |
React Typescript | Configuration |
rtk-query-demo | Configuration |
svelte-app-rtk-simplequery-demo | Configuration |
Path | Size |
---|---|
dist/rtk-query.cjs.production.min.js | 15.3 KB (+3.82% 🔺) |
dist/rtk-query.esm.js | 13.75 KB (+3.98% 🔺) |
Some things to think about.... we need to chart out all of the behavior between refetchOnFocus
/refetchOnMountOrArgChange
/refetchOnReconnect
as well as polling.
I was thinking about adding a configuration option to also skip requests in the condition when the browser is offline or unfocused. We can do that easily now that it's in the config state. The only potential downside there would be that we'd keep generating requests that get rejected, but I don't think it actually matters. This would be the cleanest way tho imo, as we wouldn't have to introduce any type of runner in the middleware, and it could just keep creating attempts that get rejected until conditions are valid.
Any thoughts there @phryneas ?
This is an idea that implements basic
refetchOnFocus
andrefetchOnReconnect
behaviors. I'm not sure if this is the best way to implement this, but wanted to throw it up here for discussion.The goal here was to keep the config in the
querySubState
so we can leverage the middleware and support these features outside of hooks usage.The other thing I was thinking was using the
configSlice
to have 'smarter' polling control... where we could just reject in the condition if it's offline, but keep the polling interval in-tact.