Skip to content

Fixed reactivity of the $asyncComputed properties #58

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

Merged
merged 1 commit into from
Jan 8, 2019

Conversation

mtorromeo
Copy link
Contributor

@mtorromeo mtorromeo commented Dec 19, 2018

This makes $asyncComputed reactive by turning it into a property of $data and manipulating it with Vue.set.

This should fix #52 and #56.


if (!this.$options.computed) this.$options.computed = {}

this.$options.computed.$asyncComputed = () => this.$data._asyncComputed
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that I had to implement a little hack here using _asyncComputed in $data and a corresponding $asyncComputed computed property to maintain backwards compatibility. This is necessary since Vue does not proxy properties that start with _ or $.

Alternatives, if backwards compatibility is not needed are:

  1. Rename $asyncComputed as simply asyncComputed.
  2. Keep only $asyncComputed in data instead of _asyncComputed, drop the unnecessary computed property and document that it should be accessed as this.$data.$asyncComputed.

@mtorromeo
Copy link
Contributor Author

@foxbenjaminfox do you think you could take a look at this, please?

Happy new year!

@foxbenjaminfox foxbenjaminfox merged commit 094cd49 into foxbenjaminfox:master Jan 8, 2019
@foxbenjaminfox
Copy link
Owner

Sorry that it took me a bit of time to come back around to this project. I've merged the PR, and soon I'll release a version to NPM with the fix.

@mtorromeo mtorromeo deleted the fix-reactive-state branch January 8, 2019 22:24
@mtorromeo
Copy link
Contributor Author

It's cool, thanks for merging!

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.

$asyncComputed.prop.updating is only set on intial evaluation
2 participants