HH\AsyncGenerator

The HH\AsyncGenerator<Tk,Tv,Ts> class

This page is a quick reference for people already familiar with the class. If this is new to you, we strongly recommend reading the introductory guides first:


Async generators are similar to PHP Generators, except that we are combining async with generators.

An async generator is just like a normal generator with the addition of allowing await statements in it because getting to the next yielded value involves getting and awaiting on an Awaitable.

WHILE THIS CLASS EXPOSES 3 METHODS, 99.9% OF THE TIME YOU WILL NOT USE THIS CLASS DIRECTLY. INSTEAD, YOU WILL USE await as IN THE CODE USING YOUR ASYNC GENERATOR. PLEASE READ THE GUIDE REFERENCED IN THIS API DOCUMENTATION FOR MORE INFORMATION. However, we document these methods for completeness in case you have a use case for them.

There are three type parameters associated with an AsyncGenerator:

  • Tk: The type of key returned by the generator
  • Tv: The type of value returned by the generator
  • Ts: The type that will be passed on a call to send()

Interface synopsis

class AsyncGenerator implements AsyncKeyedIterator {...}