Skip to content

(refocus) - Switch to visibilitychange api#1077

Merged
kitten merged 4 commits intourql-graphql:mainfrom
tatchi:refocusExchange-visibilitychange
Oct 22, 2020
Merged

(refocus) - Switch to visibilitychange api#1077
kitten merged 4 commits intourql-graphql:mainfrom
tatchi:refocusExchange-visibilitychange

Conversation

@tatchi
Copy link
Copy Markdown
Contributor

@tatchi tatchi commented Oct 21, 2020

Resolves #1063

Summary

Use the visibilitychange api.

Set of changes

  • Switch from focus to visibilitychange api

I looked at SWR and react-query code and noticed that they refetch on both focus and visibilitychange events. As you can see in the video below, visibilitychange does not fire when we switch from one window to another (while focus does). It actually makes sense since the visibility of the document does not change. According to #1063, focus has some issues so I guess it's fine to only refetch on visibilitychange?

ezgif com-gif-maker (1)

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Oct 21, 2020

🦋 Changeset detected

Latest commit: d249bd0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@urql/exchange-refocus Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kitten kitten changed the title (refocusExchange) switch to visibilitychange api (refocus) - Switch to visibilitychange api Oct 21, 2020
@kitten
Copy link
Copy Markdown
Member

kitten commented Oct 21, 2020

Thanks for picking this up! First on a small side-note, we document our changes for our automatically generated changelogs using "changeset" (that's what the comment above is about). Just check these instructions here on how to document a change here and probably mark this one as "minor": https://github.com/FormidableLabs/urql/blob/main/CONTRIBUTING.md#how-do-i-document-a-change-for-the-changelog

Comment thread exchanges/refocus/src/refocusExchange.ts Outdated
Comment thread exchanges/refocus/src/refocusExchange.ts Outdated
@tatchi
Copy link
Copy Markdown
Contributor Author

tatchi commented Oct 21, 2020

Thanks for picking this up! First on a small side-note, we document our changes for our automatically generated changelogs using "changeset" (that's what the comment above is about). Just check these instructions here on how to document a change here and probably mark this one as "minor": https://github.com/FormidableLabs/urql/blob/main/CONTRIBUTING.md#how-do-i-document-a-change-for-the-changelog

Sorry, I should have read the contributing doc before submitting my PR 😅

@tatchi tatchi requested a review from kitten October 21, 2020 20:03
Comment thread exchanges/refocus/src/refocusExchange.ts
Comment thread .changeset/dirty-dragons-try.md Outdated
Co-authored-by: Jovi De Croock <decroockjovi@gmail.com>
Copy link
Copy Markdown
Collaborator

@JoviDeCroock JoviDeCroock left a comment

Choose a reason for hiding this comment

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

Awesome work, thanks for picking this up!

@kitten kitten merged commit a7e0f0d into urql-graphql:main Oct 22, 2020
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.

RFC: Update refocusExchange to utilize Page Visibility API

3 participants