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: pause dep collection during immediate watcher invocation #11943

Merged
merged 6 commits into from Mar 30, 2021

Conversation

delaneyb
Copy link
Contributor

@delaneyb delaneyb commented Mar 7, 2021

Close #11942

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe: Performance improvement

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:

@posva posva changed the title fix #11942: pause dep collection during immediate watcher invocation fix: pause dep collection during immediate watcher invocation Mar 8, 2021
Copy link
Member

@posva posva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a unit test?

@delaneyb
Copy link
Contributor Author

delaneyb commented Mar 8, 2021

Related Vue 3 PR: vuejs/core#2765

I see the solution there pauses tracking during both the immediate and subsequent invocations, whereas my issue here covers only that immediate case. Would wrapping the calls here too interfere with other uses of the Watcher class?

if (this.user) {
try {
this.cb.call(this.vm, value, oldValue)
} catch (e) {
handleError(e, this.vm, `callback for watcher "${this.expression}"`)
}
} else {
this.cb.call(this.vm, value, oldValue)
}

Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com>
delaneyb and others added 2 commits March 11, 2021 03:40
Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com>
Copy link
Member

@posva posva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@posva posva added this to Reviewed once, needs another review in 2.6.13 Mar 11, 2021
@posva posva merged commit 987f322 into vuejs:dev Mar 30, 2021
@posva posva moved this from Reviewed once, needs another review to Done in 2.6.13 Mar 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Dep collection not paused during first invocation of immediate watchers, leading to unnecessary re-render
2 participants