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

[DO_NOT_MERGE] atom effect (V1.5) development and testing #2945

Draft
wants to merge 2 commits into
base: atom-effect-v1.5
Choose a base branch
from

Conversation

dmaskasky
Copy link
Collaborator

Summary

Uploading atomEffect v1.5 work in progress to finish development. The end goal is all tests pass.

The full implementation is provided towards this goal.

Not for merge

Current State

 ❯ |jotai| tests/atomEffect/atomEffect.test.tsx (34) 4671ms
   ✓ should run the effect on vanilla store
   ✓ should not call effect if immediately unsubscribed
   ✓ should run the effect on mount and cleanup on unmount once
   ✓ should run the effect on mount and cleanup on unmount and whenever countAtom changes
   ✓ should not cause infinite loops when effect updates the watched atom
   ✓ should not cause infinite loops when effect updates the watched atom asynchronous
   × should allow synchronous recursion with set.recurse for first run 1018ms
   × should allow synchronous recursion with set.recurse 1003ms
   × should allow multiple synchronous recursion with set.recurse
   × should batch updates during synchronous recursion with set.recurse
   ✓ should allow asynchronous recursion with task delay with set.recurse
   ✓ should allow asynchronous recursion with microtask delay with set.recurse 501ms
   × should work with both set.recurse and set 1004ms
   ✓ should disallow synchronous set.recurse in cleanup
   × should return value from set.recurse
   ✓ should conditionally run the effect and cleanup when effectAtom is unmounted
   ✓ should correctly process synchronous updates to the same atom (9) 511ms
     ✓ should correctly process synchronous updates when effectIncrementCountBy is +0 and incrementCountBy is +0
     ✓ should correctly process synchronous updates when effectIncrementCountBy is +0 and incrementCountBy is 1
     ✓ should correctly process synchronous updates when effectIncrementCountBy is +0 and incrementCountBy is 2
     ✓ should correctly process synchronous updates when effectIncrementCountBy is 1 and incrementCountBy is +0
     ✓ should correctly process synchronous updates when effectIncrementCountBy is 1 and incrementCountBy is 1
     ✓ should correctly process synchronous updates when effectIncrementCountBy is 1 and incrementCountBy is 2
     ✓ should correctly process synchronous updates when effectIncrementCountBy is 2 and incrementCountBy is +0
     ✓ should correctly process synchronous updates when effectIncrementCountBy is 2 and incrementCountBy is 1
     ✓ should correctly process synchronous updates when effectIncrementCountBy is 2 and incrementCountBy is 2
   ✓ should not batch effect setStates
   ✓ should batch synchronous updates as a single transaction
   ✓ should run the effect once even if the effect is mounted multiple times
   ✓ should abort the previous promise
   ✓ should not infinite loop with nested atomEffects
   ✓ should not rerun with get.peek
   ✓ should trigger the error boundary when an error is thrown
   ✓ should trigger an error boundary when an error is thrown in a cleanup
   ✓ should not suspend the component

Check List

  • pnpm run fix:format for formatting code and docs

Copy link

vercel bot commented Jan 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
jotai ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 17, 2025 7:59pm

Copy link

codesandbox-ci bot commented Jan 17, 2025

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.

Copy link

pkg-pr-new bot commented Jan 17, 2025

Open in Stackblitz

More templates

npm i https://pkg.pr.new/jotai@2945

commit: a1256cd

Copy link

github-actions bot commented Jan 17, 2025

LiveCodes Preview in LiveCodes

Latest commit: a1256cd
Last updated: Jan 17, 2025 7:59pm (UTC)

Playground Link
React demo https://livecodes.io?x=id/BZ5LZ8Z47

See documentations for usage instructions.

@dmaskasky dmaskasky marked this pull request as draft January 17, 2025 19:08
@dmaskasky dmaskasky changed the title push atom effect v1.5 tests for development [DO_NOT_MERGE] atom effect (V1.5) development and testing Jan 17, 2025
@dmaskasky
Copy link
Collaborator Author

dmaskasky commented Jan 17, 2025

Update: The store refactor addressed all test failures.

 ✓ |jotai| tests/atomEffect/atomEffect.test.tsx (34) 1757ms
   ✓ should run the effect on vanilla store
   ✓ should not call effect if immediately unsubscribed
   ✓ should run the effect on mount and cleanup on unmount once
   ✓ should run the effect on mount and cleanup on unmount and whenever countAtom changes
   ✓ should not cause infinite loops when effect updates the watched atom
   ✓ should not cause infinite loops when effect updates the watched atom asynchronous
   ✓ should allow synchronous recursion with set.recurse for first run
   ✓ should allow synchronous recursion with set.recurse
   ✓ should allow multiple synchronous recursion with set.recurse
   ✓ should batch updates during synchronous recursion with set.recurse
   ✓ should allow asynchronous recursion with task delay with set.recurse
   ✓ should allow asynchronous recursion with microtask delay with set.recurse 501ms
   ✓ should work with both set.recurse and set
   ✓ should disallow synchronous set.recurse in cleanup
   ✓ should return value from set.recurse
   ✓ should conditionally run the effect and cleanup when effectAtom is unmounted
   ✓ should correctly process synchronous updates to the same atom (9) 494ms
     ✓ should correctly process synchronous updates when effectIncrementCountBy is +0 and incrementCountBy is +0
     ✓ should correctly process synchronous updates when effectIncrementCountBy is +0 and incrementCountBy is 1
     ✓ should correctly process synchronous updates when effectIncrementCountBy is +0 and incrementCountBy is 2
     ✓ should correctly process synchronous updates when effectIncrementCountBy is 1 and incrementCountBy is +0
     ✓ should correctly process synchronous updates when effectIncrementCountBy is 1 and incrementCountBy is 1
     ✓ should correctly process synchronous updates when effectIncrementCountBy is 1 and incrementCountBy is 2
     ✓ should correctly process synchronous updates when effectIncrementCountBy is 2 and incrementCountBy is +0
     ✓ should correctly process synchronous updates when effectIncrementCountBy is 2 and incrementCountBy is 1
     ✓ should correctly process synchronous updates when effectIncrementCountBy is 2 and incrementCountBy is 2
   ✓ should not batch effect setStates
   ✓ should batch synchronous updates as a single transaction
   ✓ should run the effect once even if the effect is mounted multiple times
   ✓ should abort the previous promise
   ✓ should not infinite loop with nested atomEffects
   ✓ should not rerun with get.peek
   ✓ should trigger the error boundary when an error is thrown
   ✓ should trigger an error boundary when an error is thrown in a cleanup
   ✓ should not suspend the component

 Test Files  1 passed (1)
      Tests  34 passed (34)
   Start at  12:01:32
   Duration  2.34s (transform 84ms, setup 62ms, collect 157ms, tests 1.76s, environment 216ms, prepare 35ms)

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.

1 participant