-
-
Notifications
You must be signed in to change notification settings - Fork 638
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: should update dependents with the value of the unwrapped atom when the promise resolves #2920
Closed
+133
−12
Closed
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
fc05691
test: should update dependents with the value of the unwrapped atom w…
dmaskasky b975cd3
allow mount dependencies of pending promise atom but disallow unmount
dmaskasky 7addd25
handle mounting and unmounting of sync and async dependencies separately
dmaskasky cad3b8b
add failing tests
dmaskasky c5c3125
drop store changes
dmaskasky c57ce8f
test: should update dependents with the value of the unwrapped atom w…
dmaskasky 4da8912
handle mounting and unmounting of sync and async dependencies separately
dmaskasky 555738f
add failing tests
dmaskasky a1e1964
drop store changes
dmaskasky 3de6a43
Merge commit 'a1e19649c542a8ea6dbc8a0e98c3ce95dfe07419' into fix-unwr…
dai-shi 1f6fe2f
breaking: do not keep atom deps with async recalculation
dai-shi 57b2b23
remove debug store
dai-shi fc3a2d5
refactor
dai-shi b4bb8a8
Merge branch 'main' into fix-unwrap-atomEffect
dai-shi 897dc90
Merge branch 'main' into fix-unwrap-atomEffect
dai-shi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,3 +150,17 @@ describe('unwrap', () => { | |
expect(store.get(syncAtom)).toEqual('concrete') | ||
}) | ||
}) | ||
|
||
it('should update dependents with the value of the unwrapped atom when the promise resolves', async () => { | ||
const store = createStore() | ||
const asyncTarget = atom(() => Promise.resolve('value')) | ||
const target = unwrap(asyncTarget) | ||
const results: string[] = [] | ||
const derived = atom(async (get) => { | ||
await Promise.resolve() | ||
results.push('effect ' + get(target)) | ||
}) | ||
store.sub(derived, () => {}) | ||
await new Promise((r) => setTimeout(r)) | ||
expect(results).toEqual(['effect undefined', 'effect value']) | ||
}) | ||
Comment on lines
+154
to
+166
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good. So, it's a regression, right? My bad... I'll see what I can do with the impl. It will be step by step and take a bit of time. Sorry folks for waiting. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 the planned breaking change in v2.12.0.
@yuneco Will you be able to check if this breaks your app?
npm i https://pkg.csb.dev/pmndrs/jotai/commit/b4bb8a8d/jotai
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.
@yuneco Never mind! Moved to #2940.