Skip to content

Latest commit

 

History

History

16-until

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

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>

Back Share your Solutions Check out Solutions