asyncComputed is not lazy like computed
See original GitHub issueNot sure if this should be a default but, I think, there should be option to make asyncComputed
lazy like vue computed
. Right now even if you use v-if
to not render computed data it is still being retrieved.
#247 - Example of failing test
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
$asyncComputed is undefined in computed property · Issue #56
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?
Read more >asyncComputed - VueUse
Just like Vue's built-in computed function, useAsyncComputed does dependency tracking and is automatically re-evaluated when dependencies change. Note however ...
Read more >VueJS: Is it suitable to trigger async function inside computed ...
Yes, it's best to avoid an async call in a computed property. What I have done in similar situations is have a computed...
Read more >How to create and use async properties - Hacking with Swift
Just as Swift's functions can be asynchronous, computed properties can also be asynchronous: attempting to access them must also use await ...
Read more >Top Vue Packages for Adding Async Computed Properties ...
In our example, we just take the product of them and set that as the… ... However, with the addition of the vue-async-computed...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sure, I’ll work on it.
The behaviour has already described as a caveat in the doc. I am not sure if it makes sense to have
asyncComputed
lazy as in that way you will always get the null on the first access (and need to wait for the promise get resolved from that time).With https://github.com/vuejs/rfcs/pull/212 (likely in Vue 3.1), it will expose
effect
tovue
and we can makeinvalidableComputed
easily with it. However, that would be a Vue 3 only thing (Vue 2 does not haveeffect
).