DEV Community

Discussion on: JavaScript Iterators and Generators: Asynchronous Iterators

Collapse
 
eatsjobs profile image
Pasquale Mangialavori • Edited

I think we can also write it down in this succinct way. But correct me if I'm wrong

const pagination = {
  async *[Symbol.asyncIterator]() {
    let i = 0;
    while (i < 10) {
      await Promise.resolve(true);
      i++;
      yield i;
    }
  }
};

Collapse
 
jfet97 profile image
Andrea Simone Costa

Yes, but async gens are the argument of the next article eheheheh

Collapse
 
eatsjobs profile image
Pasquale Mangialavori

SPOILER ALERT then :D eheh