ajacksified / ajacksified/Mediator.js

Behaviour for publishing to non-existent channel has changed

Abierto
#36 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
JavaScript
Estrellas
460
Forks
75
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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);
...
}
```

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.