Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collect subscribers at actual emit time rather than publish-call time #59

Open
pvdz opened this issue Jul 3, 2014 · 1 comment
Open

Comments

@pvdz
Copy link

pvdz commented Jul 3, 2014

https://gist.github.com/qfox/f33a51dc7189d98efe23

Basically, this test:

PubSub.publish('foo', 'bar');
PubSub.subscribe('foo', function(name, value) {});

Currently the callback is not being fired. However, in this case they are both (which is fine).

PubSub.subscribe('foo', function(name, value) {});
PubSub.publish('foo', 'bar');
PubSub.subscribe('foo', function(name, value) {});

Due to the async nature of pubsub I expect it to evaluate target handlers at emitting time, not at call time.

This basically also means this:

var foo = PubSub.subscribe('foo', function(name, value) { throw 'No dont call me!'; });
PubSub.publish('foo', 'bar');
PubSub.unsubscribe(foo);

I expect the subscriber NOT to be called because it was removed before actually emitting the event.

@blainekasten
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants