Pause RTK Query Polling (React Native background) #5033
-
QuestionIs there a way to pause all polling intervals, and re-enable at some point later? The ScenarioMy team uses RTK Query in a Reach Native app and it generally works very well. Lots of our queries use various If I add a simple logging middleware, I can see when a polling API triggers: const apiLoggerMiddleware: Middleware = () => next => action => {
// Simple logger to show when an API fires, and its corresponding name
if (action.type.startsWith('api/execute')) {
console.log('API Request:', action?.type, action?.meta?.arg?.endpointName);
}
return next(action);
}; When I close the app (swipe up to the home screen and have it enter the background state), the polling continues. This has caused two potential issues:
Attempted solutions
I have avoided using Any suggestions here would be great, this would be really useful for anyone using this with React Native in particular. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hmm. Don't think we have any kind of way to control all polling as a whole right now, but that seems like a reasonable feature request. Filed #5034 to track it. Unfortunately we're pretty light on development activity right now - all of us maintainers are mostly busy with real life topics atm, and I don't know if/when we'd be able to get to it. If someone would like to take this on and file a PR, I'd be very happy to work with them to direct the implementation work. This would most likely require some changes to the RTKQ custom middleware that manages the polling. |
Beta Was this translation helpful? Give feedback.
Hmm. Don't think we have any kind of way to control all polling as a whole right now, but that seems like a reasonable feature request.
Filed #5034 to track it. Unfortunately we're pretty light on development activity right now - all of us maintainers are mostly busy with real life topics atm, and I don't know if/when we'd be able to get to it. If someone would like to take this on and file a PR, I'd be very happy to work with them to direct the implementation work. This would most likely require some changes to the RTKQ custom middleware that manages the polling.