Skip to content

Commit

Permalink
Stop Radio.Channel from touch Radio._channels
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiebuilds authored and jamesplease committed Aug 21, 2014
1 parent d4d60f1 commit 0d8b4ef
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/backbone.radio.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ _.extend(Radio, {
*/

Radio.Commands = {

// Issue a command
command: function(name) {
var args = slice.call(arguments, 1);
Expand Down Expand Up @@ -288,7 +288,12 @@ Radio.channel = function(channelName) {
if (!channelName) {
throw new Error('You must provide a name for the channel.');
}
return Radio._channels[channelName] || new Radio.Channel(channelName);

if (Radio._channels[channelName]) {
return Radio._channels[channelName];
} else {
return (Radio._channels[channelName] = new Radio.Channel(channelName));
}
};

/*
Expand All @@ -301,7 +306,6 @@ Radio.channel = function(channelName) {

Radio.Channel = function(channelName) {
this.channelName = channelName;
Radio._channels[channelName] = this;
};

_.extend(Radio.Channel.prototype, Backbone.Events, Radio.Commands, Radio.Requests, {
Expand Down

0 comments on commit 0d8b4ef

Please sign in to comment.