Skip to main content

v

Note

This is a point-in-time snapshot of the API documentation from January 2026. Going forward, we will not be maintaining a public copy of these references, and recommend users to refer to the built-in signature helpers available in the Hack LSP instead for complete and up-to-date information.

Translate a Traversable of Awaitables into a single Awaitable of Vector

namespace HH\Asio;

function v<Tv>(
Traversable<Awaitable<Tv>> $awaitables,
): Awaitable<Vector<Tv>>;

This function takes any Traversable object of Awaitables (i.e., each member of the Traversable is of type of Awaitable, likely from a call to a function that returned Awaitable<T>), and transforms those Awaitables into one big Awaitable Vector.

This function is called v we are returning a vector of Awaitable.

Only When you await or join the resulting Awaitable, will all of the values in the Vector within the returned Awaitable be available.

Parameters

Returns

Examples

/**
* Query an arbitrary number of URLs in parallel
* returning them as a Vector of string responses.
*/
async function get_urls(\ConstVector<string> $urls): Awaitable<Vector<string>> {
// Wrap each URL string into a curl_exec awaitable
$handles = $urls->map($url ==> \HH\Asio\curl_exec($url));

// Wait on each handle in parallel and return the results
return await \HH\Asio\v($handles);
}

<<__EntryPoint>>
async function basic_usage_main(): Awaitable<void> {
$urls = ImmVector {
"http://example.com",
"http://example.net",
"http://example.org",
};

$pages = await get_urls($urls);
foreach ($pages as $page) {
echo \substr($page, 0, 15).' ... '.\substr($page, -8);
}
}
```.skipif
// Skip if we don't have an internet connection
if (!\get_headers("www.example.com")) {
print "skip";
}