ajacksified / ajacksified/Mediator.js

Behaviour for publishing to non-existent channel has changed

Aperta
#36 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
JavaScript
Stelle
460
Fork
75
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

PR #31 introduced a change in behaviour which might break existing implementations of the Mediator. The change to `getChannel()` on the Mediator object has had an unexpected consequence.

When you have a channel named `root:sub1` and you post a message to `root:sub1:subA` the message will bubble through the hierarchy as expected. The problem is that subscribers will no longer be able to tell the message was originally posted to `root:sub1:subA`.

Before the PR this worked because the `publish` method create the non-existing `root:sub1:subA` and call the subscribers with this newly created Channel object. Due to the change the subscribers will now get called with a Channel which has a namespace `root:sub` as this is the most specific channel we were able to find.

I am not sure if this is going to cause any problems for anyone already using the Mediator from before PR #31 was merged. One possible solution could be to push the namespace the `publish` method was called with into the arguments array like this:

``` javascript
function publish(channelName) {
...
var args = Array.prototype.slice.call(arguments, 1);
args.push(channel);
args.push(channelName);
channel.publish(args);
...
}
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.