-
-
Save pvdz/f33a51dc7189d98efe23 to your computer and use it in GitHub Desktop.
// PubSub.subscribe('foo', function(name, value) {}); | |
PubSub.publish('foo', 'bar'); | |
PubSub.subscribe('foo', function(name, value) {}); |
This is similar to resolving/rejecting a promise and registering another .then
or .otherwise
after doing so. The guaranteed async behavior made me think pubsub would follow the same line.
The main difference is that I don't expect pubsub to fire events retroactively for events registered after a yield. Don't get me wrong there :) But if an event hasn't fired yet, it should fire for all events that are registered up until the point where it fires, even if there weren't any events at the time of calling .publish
.
So basically, I suspect a (imo) bug in where subscribers are collected. I think pubsub fizzles the event because there are no subscribers for it at call time. I'm sure you can confirm/reject this :)
Oh. Github didn't update. Great, should I file a ticket?
Yeah, a ticket would be great!
Thanks!
Your test is probably correct, and I think I now understand your expectation. I think that it would be the most common expectation for this scenario and that we should update PubSubJS to match it.