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

perf(reactivity): Array shift() should only trigger effect once #9056

Closed
wants to merge 138 commits into from

Conversation

johnsoncodehk
Copy link
Member

@johnsoncodehk johnsoncodehk commented Aug 27, 2023

Fix #311, fix #9149, this PR is depends on #5912.

For the following code, this PR reduces the triggering of unnecessary effects.

const arr = reactive([1, 2, 3])
effect(() => {
  for (let i = 0; i < arr.length; i++) arr[i]
  console.log(arr)
})
arr.shift()

Before output:

[ 1, 2, 3 ]
[ 2, 2, 3 ]
[ 2, 3, 3 ]
[ 2, 3, <1 empty item> ]
[ 2, 3 ]

PR output:

[ 1, 2, 3 ]
[ 2, 3 ]

@johnsoncodehk
Copy link
Member Author

johnsoncodehk commented Sep 7, 2023

For the failed tests, 1591ce1 (#9056) directly modified the test result, because now that was better result in expected.

@johnsoncodehk
Copy link
Member Author

This has been merged with #5912 to reduce review effort.

@johnsoncodehk johnsoncodehk deleted the array-effect branch September 9, 2023 04:50
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.

computed triggers watcher of sync twice
2 participants