HH\Lib\Tuple\from_async

This API is part of the Hack Standard Library, not HHVM itself.
Facebook Engineer?

This function is available as Tuple\gen() in Facebook's www repository.

Create an awaitable tuple from variadic awaitables

namespace HH\Lib\Tuple;

function from_async(
  ?Awaitable<mixed> ...$awaitables,
): Awaitable<mixed>;

Given (Awaitable<T1>, Awaitable<T2>, ...), returns Awaitable(T1, T2, ...).

Nullable Awaitables are also supported: (?Awaitable<T1>, ?Awaitable<T2>, ...) is transformed to Awaitable<(?T1, ?T2)>

This is particularly useful when combined with list assignment:

list($a, $b, $c) = await Tuple\from_async(
  foo_async(),
  bar_async(),
  baz_async(),
);

The function signature here is inaccurate as it can not be correctly expressed in Hack; this function is special-cased in the typechecker.

Parameters

  • ?Awaitable<mixed> ...$awaitables