Watch state property just once #545
Answered
by
posva
3zzy
asked this question in
Help and Questions
-
I need to await a state property (object) to contain all truthy values, and I just need it once and inside an async function so don't think watcher would help.
Wonder whats the best way to achieve this? |
Beta Was this translation helpful? Give feedback.
Answered by
posva
Jun 21, 2021
Replies: 2 comments 5 replies
-
You could do it manually without vueuse but it would be similar to their code: https://github.com/vueuse/vueuse/blob/main/packages/shared/until/index.ts#L84-L97 stop = watch(
() => myStore.myData,
(myData) => {
if (allTrue(myData)) {
// remove watcher
stop()
someFunction()
}
},
{
// depending on your code, you might need to configure these
flush,
deep,
immediate: true,
},
) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
3zzy
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could do it manually without vueuse but it would be similar to their code: https://github.com/vueuse/vueuse/blob/main/packages/shared/until/index.ts#L84-L97