Replies: 1 comment 3 replies
-
Hi! I'm just wondering, couldn't you simply write: <script setup>
const book = await store.dispatch('getItem', '/api/books/1')
// book is defined now so you can refer to it and fetch your author without any computed, can't you?
const author = await store.dispatch('getItem', book.author)
</script> |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello there,
First of all, thank you all for your brilliant work! 🎉
VueUse is a real life saver and makes Vue adoption a breeze.
I'd like to submit an idea, which is something like
asyncComputed(callback, initialState, {promise: true}
so that in this case, instead of returning thecomputed
directly, return a Promise resolved by thecomputed
.The use case is to use it along with top-level
await
with<script setup>
andSuspense
components.Example usage:
I didn't succeed in doing it by myself (TS is not my primary language as I'm more a back-end guy 😅) so I wrote a kinda crappy wrapper which does the job, but it would be great if
asyncComputed()
could do this out of the box with an opt-in option:What do you think?
Beta Was this translation helpful? Give feedback.
All reactions