Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on May 8, 2024 via composer

react/promise v3.0.0

A lightweight implementation of CommonJS Promises/A for PHP
Package summary
Share
0
issues
1
license
1
MIT
Package created
24 Oct 2012
Version published
11 Jul 2023
Maintainers
5
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
react/promise@v3.0.0
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of react/promise 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does react/promise do?

React/Promise is a PHP library providing an implementation of CommonJS Promises/A. Essentially, it helps to manage and coordinate the flow of asynchronous operations, making it a great tool for handling actions such as API calls or database operations that are not instantaneous. This library can make your code easier to read and maintain by providing a robust, canonical way to work with asynchronous operations.

How do you use react/promise?

Using React/Promise is fairly straightforward. After installation via Composer, you can start utilizing this library in your PHP codes. Here's an example of a function returning a deferred promise:

function getAsyncValue() {
    $deferred = new \React\Promise\Deferred();

    someAsynchronousFunction(function($error, $result) {
        if ($error) {
            $deferred->reject($error);
        } else {
            $deferred->resolve($result);
        }
    });

    return $deferred->promise();
}

getAsyncValue()->then(
    function ($value) {
        echo 'Value: ' . $value;
    }, 
    function ($error) {
        echo 'Error: ' . $error;
    }
);

In this example, getAsyncValue() performs an asynchronous operation and returns a promise for its result. We attach fulfillment and rejection handlers to it using then(). The fulfillment handler will be executed with the result upon success, while the rejection handler will be executed with an error upon failure.

Where are the react/promise docs?

You can find the full documentation of React/Promise on the library's Github page at https://github.com/reactphp/promise. It includes explanations of various concepts and APIs involved such as Deferred, Promise, resolve(), reject(), and so on. It also features a number of operation patterns you may come across when dealing with promises. From basic usage to detailed examples and scenarios, the documentation is a complete resource for understanding and effectively using the React/Promise library.