Polling interval for entire API #1612
Replies: 3 comments 7 replies
-
That there are subscriptions means "it is displayed on screen". And then we keep it for a (configurable) bit longer in case you do a very fast forward-backward navigation or some kind of component transition. I believe you want to use something like Tbh, I do not see a common use case for just polling everything as in most cases that would just kill every server. |
Beta Was this translation helpful? Give feedback.
-
Here is a little more verbose code to illustrate: function Layout(){
const teams = useTeamsQuery(); // refetchOnMountOrArgChange doesn't not work for these two as it doesn't unmount
const user = useUserQuery(); // the subscription count for these hooks is always 1
return (
<>
<header>
Hello {user.data.name}, you are a member of {teams.data.count} teams
<Link to="/">Dashboard</Link>
<Link to="/teams">Teams</Link>
<Link to="/company">company</Link>
</header>
<Switch>
<Route exact path="/">
<Dashboard />
</Route>
<Route exact path="/teams">
<Teams />
</Route>
<Route exact path="/company">
<CompanyDetails />
</Route>
</Switch>
</>
);
} The user name and team count will never get updated in the |
Beta Was this translation helpful? Give feedback.
-
@phryneas I think the general point is that rtk query's design works very well for a high volume, low change site like a content-based news site. Our site is a low-volume, high change site where we want users to be able to cleanly have the content updated (every 5 minutes for instance). So if the user remains on the same page and is active performing actions, they should see the updated content after a reasonable interval. |
Beta Was this translation helpful? Give feedback.
-
We are refactoring our redux store to use RTK query. For a while I was under the impression that the caching had a timer that went stale and then it refetched the data silently. I have discovered now that the cache is only deleted when all the subscriptions are removed and the timer has expired.
What we would really like is for the user to have the most up to date data regardless of whether they have nagivated away. For example the user is looking at a list of team members leaving the tab open. Someone adds a team member. The user should see the updated list after a short time (like a minute).
I realise there is a
pollingInterval
option for individual hooks, but this has to be added to every single use of the hook which makes it cumbersome to update and error prone if you forget one, especially because it's a difficult thing to test.What's the rationale for keeping the cache around forever as long as there are subscriptions? And can we have a
pollingInterval
option forcreateApi
?Beta Was this translation helpful? Give feedback.
All reactions