Skip to content

Adirelle/react-event-promise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EventPromise

EventPromise allows you to easily create Promises that react on events emitted by an EventEmitterInterface.

Listeners are automatically removed when the Promise is fulfilled, rejected or cancelled.

Build Status

Fetch

The recommended way to install EventPromise is through composer.

Just create a composer.json file for your project:

{
    "require": {
        "adirelle/react-event-promise": "@stable"
    }
}

API

Promises are created using the Adirelle\React\EventPromise\EventPromise::listen method:

use \Adirelle\React\EventPromise\EventPromise;
// ...

    EventPromise::listen($someEventEmitter, ['eventToResolve'], ['eventToReject'], ['eventToNotify'])
        ->then(
            function ($arguments) {
                echo 'Event "eventToResolve" emitted';
            },
            function ($arguments) {
                echo 'Event "eventToReject" emitted';
            },
            function ($arguments) {
                echo 'Event "eventToNotify" emitted';
            }
        );

License

EventPromise is released under the MIT license.

About

Create ReactPHP promises for events.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages