Skip to content

Add promise resolution type #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 26, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions components/promise.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
Promise
=======

When sending asynchronous HTTP requests, a promise is returned. The promise acts
as a proxy for the response or error result, which is not yet known.
A promise represents a single result of an asynchronous operation.
It is not necessarily available at a specific time, but should become in the future.

The PHP-HTTP promise follows the `Promises/A+`_ standard.

.. note::
Expand All @@ -13,8 +14,11 @@ The PHP-HTTP promise follows the `Promises/A+`_ standard.
Asynchronous requests
---------------------

Asynchronous requests enable non-blocking HTTP operations. To execute such a
request with HTTPlug::
Asynchronous requests enable non-blocking HTTP operations.
When sending asynchronous HTTP requests, a promise is returned. The promise acts
as a proxy for the response or error result, which is not yet known.

To execute such a request with HTTPlug::

$request = $messageFactory->createRequest('GET', 'http://php-http.org');

Expand All @@ -27,6 +31,9 @@ request with HTTPlug::

See :ref:`message-factory` on how to use message factories.

Although the promise itself is not restricted to resolve a specific result type,
in HTTP context it resolves a PSR-7 ``Psr\Http\Message\ResponseInterface`` or fails with an ``Http\Client\Exception``.

Wait
----

Expand Down