The resolution value of the returned promise will be the resolution value of the triggering item. The rejection reasons can be obtained with CompositeException::getExceptions.
These examples are contrived, of course, and in real usage, promise chains will typically be spread across several function calls, or even several levels of your application architecture. Resolved promises forward resolution values to the next promise. Each call to then returns a new promise that will resolve with the return value of the previous handler. This creates a promise "pipeline". Similarly, when you handle a rejected promise, to propagate the rejection, "rethrow" it by either returning a rejected promise, or actually throwing since promise translates thrown exceptions into rejections.
Mixing resolutions and rejections will still forward handler results in a predictable way.
Promise: Promise - ReactPHP
At a first glance, then and done seem very similar. However, there are important distinctions.
The intent of then is to transform a promise's value and to pass or return a new promise for the transformed value along to other parts of your code. The intent of done is to consume a promise's value, transferring responsibility for the value to your code.
In addition to transforming a value, then allows you to recover from, or propagate intermediate errors. Any errors that are not handled will be caught by the promise machinery and used to reject the promise returned by then. Calling done transfers all responsibility for errors to your code. Promise is a port of when.
Also, large parts of the documentation have been ported from the when. Skip to content.
Dismiss Join GitHub today GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together. Sign up.
PHP Branch: master New pull request. Find File. Download ZIP. Sign in Sign up.
Tickets for this event are not available.
Launching GitHub Desktop Go back. Launching Xcode Launching Visual Studio Latest commit 2bd Aug 4, Concepts Deferred A Deferred represents a computation or unit of work that may not have completed yet. Promise While a deferred represents the computation itself, a Promise represents the result of that computation.
API Deferred A deferred represents an operation whose resolution is pending. You signed in with another tab or window.
Reload to refresh your session. You signed out in another tab or window. Add missing Throwable parameter type-declarations to rejection functions. May 9, Remove FunctionalRejectTest as it only tests non-throwable rejection …. Add coveralls badge and travis config. Apr 27, Fix php-coveralls setup.
Mar 8, Update copyright year. No No No Playlists relacionadas. Mais acessados. Todos Rock Gospel Sertanejo Mais. Lalala feat.
Delivering on the Promise
Aplicativos e plugins. Mobile Android iPhone Windows Phone. Desktop Google Chrome Windows 8. Plugin W. Media Player Winamp. Meu perfil Enviar letra Mensagens Editar Sair.
Editar playlist. Tem certeza que deseja excluir esta playlist? Cancelar Excluir.