Skip to content

$asyncComputed is undefined in computed property #56

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

Closed
johannes-z opened this issue Dec 10, 2018 · 2 comments
Closed

$asyncComputed is undefined in computed property #56

johannes-z opened this issue Dec 10, 2018 · 2 comments

Comments

@johannes-z
Copy link
Contributor

I wanted to use $asyncComputed.posts.error in a computed property, but it's undefined and non-reactive. Is there a way to accomplish that?

@foxbenjaminfox
Copy link
Owner

This should be fixed as of #58.

@johannes-z
Copy link
Contributor Author

johannes-z commented Mar 5, 2019

@foxbenjaminfox

It's still initially undefined, at least when using watchers. Because of this I can't make computed properties depend on the asyncComputed state, e.g. updating.

Version used: "vue-async-computed": "^3.6.1"

computed: {
  computedProp () {
    console.log(this.$asyncComputed.asyncProp) // prints undefined
    return ''
  }
},
asyncComputed: {
  asyncProp: {
    lazy: true,
    default: () => [],
    async get () {
      return []
    }
  }
}

Edit: Please re-open, or should I create a new issue? Here is a repro: https://codesandbox.io/s/l7nno76l3q

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

No branches or pull requests

2 participants