The goal of this specification is to define an Awaitable
interface for interoperability in PHP.
An Awaitable
represents the eventual result of an asynchronous operation. The primary way of interacting with an Awaitable
is through its when
method, which registers a callback to receive either an Awaitable
's eventual value or the reason why the Awaitable
has failed. They're basically the same as a Promise
in JavaScript's Promises/A+ specification, but the interaction with them is different as the following paragraphs show.
This specification defines an interoperable Awaitable
interface for PHP, focussing on its when
method. This is required for interoperable co-routines, which can be implemented in PHP using generators. Further methods like a watch
method for progress updates are out of scope of this specification. The name Awaitable
works well if PHP is extended later to support await
and is also alraedy [used in HHVM](htt