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

multiple once for the same subscriber #49

Open
igniscom opened this issue Nov 9, 2015 · 1 comment
Open

multiple once for the same subscriber #49

igniscom opened this issue Nov 9, 2015 · 1 comment

Comments

@igniscom
Copy link

igniscom commented Nov 9, 2015

It seems that if I subscribe twice to the same channel with the same subscriber with the "once" method, then if I "publish", the channel will be executed twice for the subscriber !

I thought "once" would have meant :

  • one subscription by subscriber, avoiding multiple subscriptions for the same subscriber.
  • when published once, then unsubscribed (that part is ok).

Example :

mediator.once("test", function () { print("Hello world!"); });
mediator.once("test", function () { print("Hello world!"); });
mediator.publish("test");

...seem to print :

"Hello world!" "Hello world!"

@BloodyStupidViktor
Copy link

I believe it is working as intended. Calling once, or any other subscribing function, creates a new instance of a Subscriber. So each subscriber is different, no matter if you pass in the same arguments. It is not the same subscriber being called twice, but two different subscribers being called once.

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