Skip to content

Few parameters needed to be added for polling (if window active & if window focus) #446

@favger

Description

@favger

meta: {
pollWhenHidden: false,
revalidateOnFocus: false
}

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions