2zH / articles-collection

Chuunibyou is good!
1 stars 0 forks source link

奇淫技巧 #3

Open 2zH opened 7 years ago

2zH commented 7 years ago

Promise iterable functions:

const wait = () => new Promise((resolve) => (
      window.setTimeout(resolve, delay)
    ))
this.actionMapper.reduce((result, fn) => (
  result
    .then(wait)
    .then(fn)
  ), Promise.resolve())

Too much setTimeout, that's bad. :(