Skip to content

Watch state property just once #545

Answered by posva
3zzy asked this question in Help and Questions
Jun 20, 2021 · 2 comments · 5 replies
Discussion options

You must be logged in to vote

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,
        },
      )

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
4 replies
@userquin
Comment options

@3zzy
Comment options

@userquin
Comment options

@userquin
Comment options

Comment options

You must be logged in to vote
1 reply
@3zzy
Comment options

Answer selected by 3zzy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants