Skip to content
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

fix(utils/atomWithDefault): support refresh #537

Merged
merged 7 commits into from
Jun 23, 2021
Merged

fix(utils/atomWithDefault): support refresh #537

merged 7 commits into from
Jun 23, 2021

Conversation

dai-shi
Copy link
Member

@dai-shi dai-shi commented Jun 20, 2021

@vercel
Copy link

vercel bot commented Jun 20, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/pmndrs/jotai/GmDD8vP5v6e4Rk463xZbqxctvkhX
✅ Preview: https://jotai-git-fix-issue-521-pmndrs.vercel.app

@dai-shi
Copy link
Member Author

dai-shi commented Jun 20, 2021

@fkocovski Would you try this? (you can npm/yarn install the codesandbox build.)

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 20, 2021

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 da1199a:

Sandbox Source
React Configuration
React Typescript Configuration

@dai-shi dai-shi changed the title support refresh in atomWithDefault fix(utils/atomWithDefault): support refresh Jun 20, 2021
@LucaColonnello
Copy link
Contributor

@dai-shi I tested this with different scenarios here.

Tested the following:

  • dependency tracking refreshing default value (every time you click the Change Id button, which changes a dependency)
  • default value (async in this case)
  • set override value (done in the useEffect)
  • refresh the default value, removing the override (which calls again the getDefault function)

It seems to work perfectly fine for me in all these scenario

@dai-shi
Copy link
Member Author

dai-shi commented Jun 21, 2021

@LucaColonnello

Great to hear! and the csb example looks good too.
Would you be willing to contribute to this PR? There are two remaining tasks.

@LucaColonnello
Copy link
Contributor

Hey @dai-shi,
I'd love to yeah!

I just need to familiarise myself with the testing setup here.

I'll look around and give it a try.

Is there a discord or slack channel (or equivalent) I can join if I get stuck where I can ask for help? (I can just write here otherwise)

@dai-shi
Copy link
Member Author

dai-shi commented Jun 21, 2021

Is there a discord

Yes, please find an invitation link in readme.
There's #jotai channel in the Poimandres discord server. You can DM me too.

@LucaColonnello
Copy link
Contributor

Amazing thank you!

I'll let you know how it goes, I think I have an idea based on the existing atomWithDefault tests I've seen.

* support refresh in atomWithDefault

* test: tests for atomWithDefault refresh feature

* chore: update size-snapshot.json

Co-authored-by: daishi <daishi@axlight.com>
@LucaColonnello
Copy link
Contributor

About the above failing test, I wasn't sure it was an environment issue (my local machine), but the waitForAll tests seem to be intermittently failing, and it seems unrelated to the changes on atomWithDefault.

@dai-shi
Copy link
Member Author

dai-shi commented Jun 22, 2021

the waitForAll tests seem to be intermittently failing

Yeah, I've seen this a few times. @Thisen can you investigate it? (but the reproduction is gone...)

@dai-shi dai-shi marked this pull request as ready for review June 22, 2021 22:53
@dai-shi
Copy link
Member Author

dai-shi commented Jun 22, 2021

Thanks to @LucaColonnello , this is ready for review and merge. Anyone, feel free to leave some comments.

@dai-shi
Copy link
Member Author

dai-shi commented Jun 23, 2021

the waitForAll tests seem to be intermittently failing

Yeah, I've seen this a few times. @Thisen can you investigate it? (but the reproduction is gone...)

Okay, this is probably my bad. I commented out jest.useFakeTimers().
@Thisen Will you still help me? How can we comment this in?

@Thisen
Copy link
Collaborator

Thisen commented Jun 23, 2021

Should be fixed now.

@dai-shi dai-shi merged commit 775790e into master Jun 23, 2021
@dai-shi dai-shi deleted the fix/issue-521 branch June 23, 2021 12:18
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.

async set atom remains cached
3 participants