foxbenjaminfox/vue-async-computed

$asyncComputed is undefined in computed property

johannes-z opened this issue · 2 comments

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?

This should be fixed as of #58.

@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