Skip to content

How to make a component wait for an async in a composable? #7517

Answered by LinusBorg
3aluw asked this question in Help/Questions
Discussion options

You must be logged in to vote

if the object has the value property why accessing it returns null ?
It has the property, but the values hasn't been assigned yet at that moment as the async function is still runnning.

when you look at it in the console, you likely look at it after the value has been assigned, so now it works.

How to make user.get function waits to initUser() to fullfill ?

You generally would not. You would use a v-if in the component's template to not render the conent in question until the user is present. reactivity will take care of the rest.

<div v-if="Deskree.user.get().value">

In advanced scenarios you can await code in setup but that requires using the experimental Suspense component and is u…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by 3aluw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants