HH\AsyncGenerator

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()

Guide

Interface Synopsis

namespace HH;

final class AsyncGenerator implements AsyncKeyedIterator<Tk, Tv> {...}

Public Methods