ajacksified / ajacksified/Mediator.js
Behaviour for publishing to non-existent channel has changed
- Ngôn ngữ chính
- JavaScript
- Star
- 460
- Fork
- 75
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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);
...
}
```
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Đánh giá
Issue này chưa được đánh giá.