You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$emitter = newEmitter();
$emitter->addListener('foobar', function () {
echo'a';
}, 50);
$emitter->addListener('foobar', function () {
echo'b';
}, 0);
$emitter->addListener('foobar', function () {
echo'c';
}, 0);
$emitter->addListener('foobar', function () {
echo'd';
}, -50);
$emitter->emit('foobar');
Now, as C was registered after B, I would expect it to fire after B too, but currently instead of abcd I get acbd. Is this expected behaviour? Is there any way to avoid this?
The text was updated successfully, but these errors were encountered:
I've opened a PR #45 which adds a new sort function that is stable. The emitter is using usort which is not stable so the order of elements that are deemed equivalent by the comparison function is not guaranteed to remain the same as in the original array. PR #45 should fix that and you'll get abcd.
Consider the following code:
Now, as C was registered after B, I would expect it to fire after B too, but currently instead of
abcd
I getacbd
. Is this expected behaviour? Is there any way to avoid this?The text was updated successfully, but these errors were encountered: