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

Channels are not called recursively if the first one is not matched #47

Closed
BloodyStupidViktor opened this issue May 26, 2015 · 6 comments

Comments

@BloodyStupidViktor
Copy link

If I listen to 'x:y' and I emit to 'x:y:z', my listener won't trigger. However, if I add a listener for 'x:y:z', then both will trigger. Is this intended? I would expect all 'parent' channels to be visited always, regardless of any gaps in the listeners.
What is the purpose of the namespace check in Mediator.publish? It seems to be the cause.

Best regards

@majkel89
Copy link

majkel89 commented Jul 1, 2015

Does not work for me too.
Version 0.9.6 seems to be fine.

@karol-f
Copy link

karol-f commented Nov 5, 2015

+1

Code responsible for this is

publish: function(channelName){
      var channel = this.getChannel(channelName || "", true);

The "true" boolean changes behaviour in 0.9.8. From comment i can see that it works other way around than I thought - you publish to let say 'chat:message' and subscribe to 'chat:message:received' and get notified.

To be honest previous behaviour of subscribing to 'chat:message' and publishing 'chat:message:received' was better suited to my needs (and looking at comments - for others too).

We can change to var channel = this.getChannel(channelName || "", false); but won't that break other functionality?

@BloodyStupidViktor
Copy link
Author

Oh, never thought it might work that way. I even find this behavior a bit strange. 'chat:message:received' is a specific 'chat:message' event and triggering it from any 'chat:message' just seems wrong. I'd expect it to be the other way around.

pedroetb pushed a commit to pedroetb/Mediator.js that referenced this issue Apr 8, 2016
@pedroetb
Copy link
Contributor

pedroetb commented Apr 8, 2016

PR send to apply the change commented by @karol-f

About that comment inside the source, I think it's not correct. The publication doesn't propagate from top to bottom, even with that "readOnly" flag set to true. It makes no sense, it works just the opposite way (from bottom to top).

@nicolaslaplume
Copy link

👍

@ajacksified
Copy link
Owner

PR merged

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

6 participants