Skip to content

enhance: move online listeners to config (#474) #476

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

Merged
merged 6 commits into from
Jul 25, 2020

Conversation

huozhi
Copy link
Member

@huozhi huozhi commented Jun 19, 2020

Changes

Resolves #474 , attach online event listeners in config

Test Plan

  • build swr locally and yarn link to the examples/focus-revalidate
  • add one more swr hook there
  • disconnect and reconnect the network in devtools
  • expected: the requests get re-fetched

Copy link
Member

@shuding shuding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need the extra RECONNECT_REVALIDATORS 🤔. Can we use the same FOCUS_REVALIDATORS (and rename it to just REVALIDATORS?

@huozhi
Copy link
Member Author

huozhi commented Jun 21, 2020

I think we don't need the extra RECONNECT_REVALIDATORS 🤔. Can we use the same FOCUS_REVALIDATORS (and rename it to just REVALIDATORS?

we still have CACHE_REVALIDATORS and it works in a different way, i guess they might not able to merge 3 of them together? if revalidators for "focus" and "reconnect" are megerable, do you feel ok to call it "ONLINE_FOCUS_REVALIDATORS"? or any other better ideas about it?

@huozhi
Copy link
Member Author

huozhi commented Jun 21, 2020

oops, looks like if we still have to separate reconnect and focus revalidators? when you disable revalidateOnFocus, first callback in FOCUS_REVALITORS still get executed even it's actually the one for reconnect

@huozhi huozhi force-pushed the config-reconnect branch from 44f9e18 to 45ee8be Compare June 21, 2020 09:35
@huozhi huozhi requested a review from shuding June 21, 2020 09:39
@huozhi huozhi force-pushed the config-reconnect branch from 0b1b0be to c5d217e Compare July 3, 2020 08:10
@@ -5,7 +5,7 @@ export default (req, res) => {
res.json({
loggedIn: true,
name: 'Shu',
avatar: 'https://github.com/quietshu.png'
avatar: 'https://github.com/shuding.png'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! 🤣

src/use-swr.ts Outdated
Comment on lines 559 to 560
CACHE_REVALIDATORS[key].push(onUpdate)
}
Copy link
Member

@shuding shuding Jul 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@huozhi huozhi requested a review from shuding July 25, 2020 17:57
@shuding shuding merged commit 004159e into vercel:master Jul 25, 2020
@huozhi huozhi deleted the config-reconnect branch July 25, 2020 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move the online event listener to config
2 participants