-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feature: provide config.isPaused indicating idle state and stop revalidation #845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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 5af2834:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good start! We can have built-in beforeunload
event handling and other features based on this. 2 questions:
Why using a function (isIdle: () => boolean
) instead of a value (isIdle: boolean
)? Value should be more consistent with our existing APIs. Another concern is that I think pause
might be a better name, idle
makes me feel that it means SWR is currently not active (not fetching anything).
@shuding Thanks for the nice feedback! I was thinking the will update PR by comments 🙏 |
But the behavior of this option is to pause requests right (everything will be skipped)? |
yup, I've changed to isPuased() { return document.visibility === 'hidden' } and add one more case in revalidation catch branch, which is ignoring the errors when promises are been rejected under paused state |
Thanks, this is a good fix! |
Description
give user ability to decide whether they want revalidation in some edge cases:
Changes
config.isPaused()
config.isPaused()
istrue
related discussion 841