sabre/event 3 released
We just released sabre/event 3. This is a new major version, and comes with a number of new features and also BC breaking changes.
This package now requires PHP 5.5. The 2.0 version of this package will continue to be maintained though if you need PHP 5.4 support.
Changes to Promises
We've overhauled the promise significantly to closely match the standard Ecmascript promise as close as possible.
To do this, we added the following functions:
Sabre\Event\Promise\all Sabre\Event\Promise\race Sabre\Event\Promise\resolve Sabre\Event\Promise\reject
These are now straight up functions, and not static methods on the Promise object.
The following methods were added:
Wait makes a lot of sense for PHP so it was added as a core feature.
The following methods were deprecated:
Both will still work but will be removed in version 4.0.
error was renamed to
catch, but we can't use that name in PHP because it's a reserved
keyword. Other projects such as ReactPHP and Guzzle have settled on the name
otherwise, so we're following their example.
Another change is that promise now uses the Event Loop to trigger events. This means that events are now predictably asynchronously triggered, whereas before events might have triggered synchronously.
What generally means is that you might need to explicitly call the
function on your promise to wait for it to resolve. Or you can call:
See the Promise documentation for more information.
We've added support for coroutines using PHP 5.5 generators. For a great example check out the documentation.
We added an implementation of an Event Loop, also sometimes known as the
ReactPHP's loop. The event loop can handle 'timed events' a.k.a.
setInterval() and support for events on IO streams
stream_select() as the underlying engine. See the
Loop documentation for more information.
A full changelog can be found on Github