|
Answer» Promises becomes very important when it comes to asynchronous COMMUNICATION and it also provides effective ways to manage resources. - A PROMISE is an object that may produce a single value sometime time in the future: either a resolved value, or a reason that it’s not resolved (e.g., a network error OCCURRED). A promise may be in one of 3 possible states: fulfilled, rejected, or pending. Promise users can attach callbacks to handle the fulfilled value or the reason for rejection.
- It started with JS but has been implemented in variety of technologies including PHP.
- Some libraries we can USE to implement promises in PHP:
- https://github.com/guzzle/promises
- https://github.com/reactphp/promise
|