Skip to content

until medium #Utility Function

By webfansplz @webfansplz

Take the Challenge    简体中文

We always need to rely on the asynchronous return result in order to do something, and the until function is so useful in this scenario. Can you do it? Lets try it 👇:

<script setup lang='ts'>
import { ref } from "vue"

const count = ref(0)

/**
 * Implement the until function
*/

function until(initial) {
  function toBe(value) {

  }

  return {
    toBe,
  }
}

async function increase() {
  count.value = 0
  setInterval(() => {
    count.value++
  }, 1000)
  await until(count).toBe(3)
  console.log(count.value === 3) // Make sure the output is true
}

</script>

Share your Solutions Check out Solutions

Get your Official Vue.js Certification for up to 47% OFF
Built under review by Evan You, creator of Vue.js
Get Certified