sailei1 / blog

1 stars 0 forks source link

Promise loop #118

Closed sailei1 closed 1 year ago

sailei1 commented 1 year ago
loop(fn,time=1000) {
      return new Promise( (resolve, reject)=> {
        setTimeout(()=>{
          // resolve(fn);
          fn()
          this.loop(fn)
        }, time);
      })
    }

//调用 
this.loop(()=>{this.getPointbyRandom(viewer)})