sabre-io / event Goto Github PK
View Code? Open in Web Editor NEW:bell: The sabre/event library provides utilities for lightweight event-based programming
Home Page: http://sabre.io/event/
License: BSD 3-Clause "New" or "Revised" License
:bell: The sabre/event library provides utilities for lightweight event-based programming
Home Page: http://sabre.io/event/
License: BSD 3-Clause "New" or "Revised" License
Hi there!,
I was looking trough your promise implementation and was building my own class form it. I have a call back on then() that echo's hello world and when i run $promise->reject(new Exception('...')); on the promise instance also then() it triggered first.
This might lead to potential bugs right? This might be the case if you change any state of your app in a then() function.
https://github.com/fruux/sabre-event/blob/master/lib/Promise.php#L263
I have just downloaded sabre/event 5.0.2 through composer, but now everytime i try to use it, i get the following 2 errors:
Warning: Unsupported declare 'strict_types' in vendor/sabre/event/lib/coroutine.php on line 1
Parse error: syntax error, unexpected ':', expecting '{' in vendor/sabre/event/lib/coroutine.php on line 48
Any idea, how to fix this?
In version 5.0 I think you renamed the interface to EmitterInterface
but Emitter
still implements EventEmitterInterface
Observed: Sabre emits a notice.
Desired: Prevent that notice, or add a configurable way for applications using sabre\event to suppress that notice
Context: This was seen in an application calling pcntl_signal() to listen for signals, then calling pcntl_fork() to create child processes (it would get signalled from within the sabre event loop)
reactphp/reactphp#296 mentions a similar issue.
See the note in https://secure.php.net/manual/en/function.stream-select.php#refsect1-function.stream-select-returnvalues
This happens in 5.0.3, probably also in master: https://github.com/sabre-io/event/blob/5.0.3/lib/Loop/Loop.php#L305
The approach taken by reactphp looks like it was to call set_error_handler before the stream operation (e.g. stream_select()), and call restore_error_handler immediately after (and check if the error was caused by pcntl in that handler)
/path/to/vendor/sabre/event/lib/Loop/Loop.php:305 [2] stream_select(): unable to select [4]: Interrupted system call (max_fd=0)
#0 my_custom_error_handler()
#1 stream_select() called at [/path/to/vendor/sabre/event/lib/Loop/Loop.php:305]
#2 Sabre\Event\Loop\Loop->runStreams() called at [/path/to/vendor/sabre/event/lib/Loop/Loop.php:233]
#3 Sabre\Event\Loop\Loop->tick() called at [/path/to/vendor/sabre/event/lib/Loop/Loop.php:194]
#4 Sabre\Event\Loop\Loop->run() called at [/path/to/vendor/sabre/event/lib/Loop/functions.php:122]
#5 Sabre\Event\Loop\run() called at ...
I can work around this by changing my_custom_error_handler
While working on sabre-io/dav#1037
I noticed that this line uses an undefined variable: listenersIndex
https://github.com/sabre-io/event/blob/master/lib/WildcardEmitterTrait.php#L170
It accidentally seems to work since PHP allows defining object properties dynamically...
Either the declaration is missing or this is a typo and the intended property name is listenerIndex
.
The Node.js EventEmitter#removeAllListeners() method shows the eventName
to be an optional parameter, but it is required in saber-event.
Code I called:
$eventEmitter->removeAllListeners();
Which produced the following error:
Missing argument 1 for Sabre\Event\EventEmitter::removeAllListeners()
The expected result is to remove ALL event listeners with any name.
atm this repositories project url points to http://sabre.io
but http://sabre.io/event/
would be more appropriate?
see #64 (comment)
Hello :-),
In the Section "The innovation: chaining”, there is a typo in the code. The example is:
$multiHttp = new MultiHttp();
$multiHttp->addRequest('DELETE', '/blogpost2.txt', '...')
->then(
function($value) {
// The DELETE request was successful!
return $multiHttp->addRequest('PUT', '/blogpost2.txt', '...');
}
)
…
However, the $multiHttp
variable inside the first anonymous function is not syntactically closed (out of the scope). The example might be the following:
function($value) use ($multiHttp) {
// The DELETE request was successful!
return $multiHttp->addRequest('PUT', '/blogpost2.txt', '...');
}
Thoughts?
Hi, this library should requite php 5.5, but In one of the examples a function is imported using "use function" that is only supported from php 5.6 onwards.
This is a minor problem since it only targets one of the examples scripts, and i only noticed it when running a php5.5-based ioncube version on the code.
just created a stripped down version of the EventEmitter which is PHP 5.3 compatible and shares the same public API.
This was required for a project which runs on a lot of systems, so we are bound to php 5.3 for the next 6 months or so until all are finally upgraded. Until then I use this EventEmitter as a drop-in replacement.
Maybe its helpfull for some others for the time beeing.
Have gone through this library and want to give it a try BUT I have always avoided using Composer mainly because I love to know what's being loaded and what extra dependence gets installed.
not using Composer means I never get lazy.
Going through https://github.com/sabre-io/event/blob/master/composer.json , I see the only dependency is PHP . I know that means I could do manual installation BUT I just want to ask to be super extra sure.
Asking also because I'm actually more interested in your HTTP library which requires this library as dependency so I checked this out so I could install both manually
PHP 7 has Generator::getReturn()
to get the return value of a generator. That means code like this is possible:
coroutine(function () {
$x = yield someAsync();
if ($x->whatever) {
return 'thisvalue';
}
$y = yield someOtherAsync();
if ($y->whatever) {
return 'thatvalue';
}
return yield $y->whatelse();
But currently coroutines will always use the last yield
value, which makes control flow like above weird.
Promise\all()
currently takes an array. Since it only iterates through it, that is an unneeded extra array conversion if you are working with Iterators / Generators.
5.1.0...master doesn't seem to have any breaking changes to the source code that would affect applications using this library - just changes to documentation, supported versions, tools for local developement, and supported php versions.
--ignore-platform-reqs
. PHP 8.0.0 stable will be released on November 26 (https://wiki.php.net/todo/php80) and this will make it easier for users to install applications using sabre/event with 8.0 betas/RCsThat is also how Promises/A+ spec behaves. It is very useful to register the fulfill function as an event handler for example and get the promise resolved as soon as it is called, no matter if it will be called more times afterwards.
See discussion #114 (comment)
We can only do this after local type aliases are supported in various non-Class places. i.e. after issue phpstan/phpstan#9164 has been implemented in phpstan.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.