vuejs-challenges icon indicating copy to clipboard operation
vuejs-challenges copied to clipboard

16 - until

Open undefined-zzk opened this issue 1 year ago • 0 comments

// 你的答案

`

const count = ref(0)

/**

  • Implement the until function */

function until(initial:Ref) { function toBe(value:number) { return new Promise(resolve=>{ const stopWatch= watchEffect(()=>{ if(initial.value>=value){ stopWatch() resolve(true) } },{flush:'post'}) }) } 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 }

`

undefined-zzk avatar Feb 07 '24 05:02 undefined-zzk