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: don't invoke Vue getters in setter #786

Merged
merged 1 commit into from Aug 14, 2021
Merged

Conversation

chearon
Copy link
Contributor

@chearon chearon commented Aug 13, 2021

This fixes the codepen in the OP of #498 as well as in the application I'm working on.

I'm hoping it's valid to keep the internal value up-to-date rather than invoking the getter each time: I'm unable to prove that hypothesis wrong. It does assume that getter will return the last value passed to setter, but Vue 2's reactive getter/setters do that. I ran the tests with logging if they are different, and verified that situation never happens in the tests.

I believe infinite loops can still happen if you create a reactive object directly (reactive() or set()) or indirectly (obj.x = {}) but this PR solves most of it.

Fixes #498

@chearon chearon changed the title fix: don't invoke Vue getters in settter fix: don't invoke Vue getters in setter Aug 13, 2021
@antfu
Copy link
Member

antfu commented Aug 14, 2021

Thanks a lot!

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 watchEffect infinite loop with vue 2, fine with vue 3
2 participants