-
-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Labels
Description
meta: {
pollWhenHidden: false,
revalidateOnFocus: false
}
redux-requests/packages/redux-requests/src/middleware/create-polling-middleware.js
Lines 44 to 53 in 0176826
| if ( | |
| config.isRequestAction(action) && | |
| config.isRequestActionQuery(action) && | |
| action.meta?.poll && | |
| !action.meta.polled | |
| ) { | |
| intervals[getIntervalKey(action)] = setInterval(() => { | |
| store.dispatch({ ...action, meta: { ...action.meta, polled: true } }); | |
| }, action.meta.poll * 1000); | |
| } |
Something like this (pollWhenHidden):
intervals[getIntervalKey(action)] = setInterval(() => {
const isWindowActive = store.getState().requests.isWindowActive;
if(action.meta.pollWhenHidden === false && !isWindowActive) return;
store.dispatch({ ...action, meta: { ...action.meta, polled: true } });
}, action.meta.poll * 1000);Something like this (revalidateOnFocus):
window.addEventListener("focus", () => {
if(action.meta?.poll && action.meta.revalidateOnFocus === true){
store.dispatch({ ...action, meta: { ...action.meta, polled: true } });
}
}@klis87 We need your help in this matter.
It's going to be a super but super thing if we integrate it into the library.
Reactions are currently unavailable