backbone.radio
Advanced tools
Comparing version 0.8.4 to 0.8.5
{ | ||
"name": "backbone.radio", | ||
"version": "0.8.4", | ||
"version": "0.8.5", | ||
"homepage": "https://github.com/marionettejs/backbone.radio", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -1,2 +0,2 @@ | ||
// Backbone.Radio v0.8.4 | ||
// Backbone.Radio v0.8.5 | ||
(function(root, factory) { | ||
@@ -23,3 +23,3 @@ if (typeof define === 'function' && define.amd) { | ||
Radio.VERSION = '0.8.4'; | ||
Radio.VERSION = '0.8.5'; | ||
@@ -67,3 +67,4 @@ // This allows you to run multiple instances of Radio on the same | ||
for (var key in name) { | ||
results.push(obj[action].apply(obj, [key, name[key]].concat(rest))); | ||
var result = obj[action].apply(obj, [key, name[key]].concat(rest)); | ||
eventSplitter.test(key) ? (results = results.concat(result)) : results.push(result); | ||
} | ||
@@ -70,0 +71,0 @@ return results; |
@@ -1,4 +0,4 @@ | ||
// Backbone.Radio v0.8.4 | ||
// Backbone.Radio v0.8.5 | ||
!function(a,b){if("function"==typeof define&&define.amd)define(["backbone","underscore"],function(a,c){return b(a,c)});else if("undefined"!=typeof exports){var c=require("backbone"),d=require("underscore");module.exports=b(c,d)}else b(a.Backbone,a._)}(this,function(a,b){"use strict";function c(a,b,c){if(k.DEBUG){var d=c?" on the "+c+" channel":"";console&&console.warn&&console.warn(a+d+': "'+b+'"')}}function d(a,b,c,d){if(!c)return!1;var e=[];if("object"==typeof c){for(var f in c)e.push(a[b].apply(a,[f,c[f]].concat(d)));return e}if(l.test(c)){for(var g=c.split(l),h=0,i=g.length;i>h;h++)e.push(a[b].apply(a,[g[h]].concat(d)));return e}return!1}function e(a,b,c){var d=c[0],e=c[1],f=c[2];switch(c.length){case 0:return a.call(b);case 1:return a.call(b,d);case 2:return a.call(b,d,e);case 3:return a.call(b,d,e,f);default:return a.apply(b,c)}}function f(a,b,c,d){var e=a[b];return c&&c!==e.callback&&c!==e.callback._callback||d&&d!==e.context?void 0:(delete a[b],!0)}function g(a,c,d,e){a||(a={});for(var g=c?[c]:b.keys(a),h=!1,i=0,j=g.length;j>i;i++)c=g[i],a[c]&&f(a,c,d,e)&&(h=!0);return h}function h(a){return m[a]||(m[a]=b.partial(k.log,a))}function i(a){return b.isFunction(a)?a:function(){return a}}var j=a.Radio,k=a.Radio={};k.VERSION="0.8.4",k.noConflict=function(){return a.Radio=j,this},k.DEBUG=!1;var l=/\s+/,m={};b.extend(k,{log:function(a,c){var d=b.rest(arguments,2);console.log("["+a+'] "'+c+'"',d)},tuneIn:function(a){var b=k.channel(a);return b._tunedIn=!0,b.on("all",h(a)),this},tuneOut:function(a){var b=k.channel(a);return b._tunedIn=!1,b.off("all",h(a)),delete m[a],this}}),k.Commands={command:function(a){var f=b.rest(arguments);if(d(this,"command",a,f))return this;var g=this.channelName,h=this._commands;if(g&&this._tunedIn&&k.log.apply(this,[g,a].concat(f)),h&&(h[a]||h["default"])){var i=h[a]||h["default"];f=h[a]?f:arguments,e(i.callback,i.context,f)}else c("An unhandled command was fired",a,g);return this},comply:function(a,b,e){return d(this,"comply",a,[b,e])?this:(this._commands||(this._commands={}),this._commands[a]&&c("A command was overwritten",a,this.channelName),this._commands[a]={callback:b,context:e||this},this)},complyOnce:function(a,c,e){if(d(this,"complyOnce",a,[c,e]))return this;var f=this,g=b.once(function(){return f.stopComplying(a),c.apply(this,arguments)});return this.comply(a,g,e)},stopComplying:function(a,b,e){return d(this,"stopComplying",a)?this:(a||b||e?g(this._commands,a,b,e)||c("Attempted to remove the unregistered command",a,this.channelName):delete this._commands,this)}},k.Requests={request:function(a){var f=b.rest(arguments),g=d(this,"request",a,f);if(g)return g;var h=this.channelName,i=this._requests;if(h&&this._tunedIn&&k.log.apply(this,[h,a].concat(f)),i&&(i[a]||i["default"])){var j=i[a]||i["default"];return f=i[a]?f:arguments,e(j.callback,j.context,f)}c("An unhandled request was fired",a,h)},reply:function(a,b,e){return d(this,"reply",a,[b,e])?this:(this._requests||(this._requests={}),this._requests[a]&&c("A request was overwritten",a,this.channelName),this._requests[a]={callback:i(b),context:e||this},this)},replyOnce:function(a,c,e){if(d(this,"replyOnce",a,[c,e]))return this;var f=this,g=b.once(function(){return f.stopReplying(a),i(c).apply(this,arguments)});return this.reply(a,g,e)},stopReplying:function(a,b,e){return d(this,"stopReplying",a)?this:(a||b||e?g(this._requests,a,b,e)||c("Attempted to remove the unregistered request",a,this.channelName):delete this._requests,this)}},k._channels={},k.channel=function(a){if(!a)throw new Error("You must provide a name for the channel.");return k._channels[a]?k._channels[a]:k._channels[a]=new k.Channel(a)},k.Channel=function(a){this.channelName=a},b.extend(k.Channel.prototype,a.Events,k.Commands,k.Requests,{reset:function(){return this.off(),this.stopListening(),this.stopComplying(),this.stopReplying(),this}});var n,o,p=[a.Events,k.Commands,k.Requests];return b.each(p,function(a){b.each(a,function(a,c){k[c]=function(a){return o=b.rest(arguments),n=this.channel(a),n[c].apply(n,o)}})}),k}); | ||
!function(a,b){if("function"==typeof define&&define.amd)define(["backbone","underscore"],function(a,c){return b(a,c)});else if("undefined"!=typeof exports){var c=require("backbone"),d=require("underscore");module.exports=b(c,d)}else b(a.Backbone,a._)}(this,function(a,b){"use strict";function c(a,b,c){if(k.DEBUG){var d=c?" on the "+c+" channel":"";console&&console.warn&&console.warn(a+d+': "'+b+'"')}}function d(a,b,c,d){if(!c)return!1;var e=[];if("object"==typeof c){for(var f in c){var g=a[b].apply(a,[f,c[f]].concat(d));l.test(f)?e=e.concat(g):e.push(g)}return e}if(l.test(c)){for(var h=c.split(l),i=0,j=h.length;j>i;i++)e.push(a[b].apply(a,[h[i]].concat(d)));return e}return!1}function e(a,b,c){var d=c[0],e=c[1],f=c[2];switch(c.length){case 0:return a.call(b);case 1:return a.call(b,d);case 2:return a.call(b,d,e);case 3:return a.call(b,d,e,f);default:return a.apply(b,c)}}function f(a,b,c,d){var e=a[b];return c&&c!==e.callback&&c!==e.callback._callback||d&&d!==e.context?void 0:(delete a[b],!0)}function g(a,c,d,e){a||(a={});for(var g=c?[c]:b.keys(a),h=!1,i=0,j=g.length;j>i;i++)c=g[i],a[c]&&f(a,c,d,e)&&(h=!0);return h}function h(a){return m[a]||(m[a]=b.partial(k.log,a))}function i(a){return b.isFunction(a)?a:function(){return a}}var j=a.Radio,k=a.Radio={};k.VERSION="0.8.5",k.noConflict=function(){return a.Radio=j,this},k.DEBUG=!1;var l=/\s+/,m={};b.extend(k,{log:function(a,c){var d=b.rest(arguments,2);console.log("["+a+'] "'+c+'"',d)},tuneIn:function(a){var b=k.channel(a);return b._tunedIn=!0,b.on("all",h(a)),this},tuneOut:function(a){var b=k.channel(a);return b._tunedIn=!1,b.off("all",h(a)),delete m[a],this}}),k.Commands={command:function(a){var f=b.rest(arguments);if(d(this,"command",a,f))return this;var g=this.channelName,h=this._commands;if(g&&this._tunedIn&&k.log.apply(this,[g,a].concat(f)),h&&(h[a]||h["default"])){var i=h[a]||h["default"];f=h[a]?f:arguments,e(i.callback,i.context,f)}else c("An unhandled command was fired",a,g);return this},comply:function(a,b,e){return d(this,"comply",a,[b,e])?this:(this._commands||(this._commands={}),this._commands[a]&&c("A command was overwritten",a,this.channelName),this._commands[a]={callback:b,context:e||this},this)},complyOnce:function(a,c,e){if(d(this,"complyOnce",a,[c,e]))return this;var f=this,g=b.once(function(){return f.stopComplying(a),c.apply(this,arguments)});return this.comply(a,g,e)},stopComplying:function(a,b,e){return d(this,"stopComplying",a)?this:(a||b||e?g(this._commands,a,b,e)||c("Attempted to remove the unregistered command",a,this.channelName):delete this._commands,this)}},k.Requests={request:function(a){var f=b.rest(arguments),g=d(this,"request",a,f);if(g)return g;var h=this.channelName,i=this._requests;if(h&&this._tunedIn&&k.log.apply(this,[h,a].concat(f)),i&&(i[a]||i["default"])){var j=i[a]||i["default"];return f=i[a]?f:arguments,e(j.callback,j.context,f)}c("An unhandled request was fired",a,h)},reply:function(a,b,e){return d(this,"reply",a,[b,e])?this:(this._requests||(this._requests={}),this._requests[a]&&c("A request was overwritten",a,this.channelName),this._requests[a]={callback:i(b),context:e||this},this)},replyOnce:function(a,c,e){if(d(this,"replyOnce",a,[c,e]))return this;var f=this,g=b.once(function(){return f.stopReplying(a),i(c).apply(this,arguments)});return this.reply(a,g,e)},stopReplying:function(a,b,e){return d(this,"stopReplying",a)?this:(a||b||e?g(this._requests,a,b,e)||c("Attempted to remove the unregistered request",a,this.channelName):delete this._requests,this)}},k._channels={},k.channel=function(a){if(!a)throw new Error("You must provide a name for the channel.");return k._channels[a]?k._channels[a]:k._channels[a]=new k.Channel(a)},k.Channel=function(a){this.channelName=a},b.extend(k.Channel.prototype,a.Events,k.Commands,k.Requests,{reset:function(){return this.off(),this.stopListening(),this.stopComplying(),this.stopReplying(),this}});var n,o,p=[a.Events,k.Commands,k.Requests];return b.each(p,function(a){b.each(a,function(a,c){k[c]=function(a){return o=b.rest(arguments),n=this.channel(a),n[c].apply(n,o)}})}),k}); | ||
//# sourceMappingURL=backbone.radio.min.js.map |
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://github.com/marionettejs/backbone.radio", | ||
"version": "0.8.4", | ||
"version": "0.8.5", | ||
"homepage": "https://github.com/marionettejs/backbone.radio", | ||
@@ -8,0 +8,0 @@ "main": "build/backbone.radio.js", |
@@ -284,3 +284,3 @@ # Backbone.Radio | ||
Make a request for `requestName`. Optionally pass arguments to send along to the callback. Returns the reply, if one | ||
exists. If there is no request then `undefined` will be returned. | ||
exists. If there is no reply registered then `undefined` will be returned. | ||
@@ -287,0 +287,0 @@ You can make multiple requests at once by using the space-separated syntax. |
@@ -48,3 +48,4 @@ var previousRadio = Backbone.Radio; | ||
for (var key in name) { | ||
results.push(obj[action].apply(obj, [key, name[key]].concat(rest))); | ||
var result = obj[action].apply(obj, [key, name[key]].concat(rest)); | ||
eventSplitter.test(key) ? (results = results.concat(result)) : results.push(result); | ||
} | ||
@@ -51,0 +52,0 @@ return results; |
@@ -515,2 +515,27 @@ describe('Requests:', function() { | ||
}); | ||
describe('when calling `request` with object with space-separated keys of requests', function() { | ||
beforeEach(function() { | ||
this.Requests.reply('requestOne', 'replyOne'); | ||
this.Requests.reply('requestTwo', 'replyTwo'); | ||
this.Requests.reply('requestThree', 'replyThree'); | ||
this.Requests.request({ | ||
'requestOne requestTwo' : 'argOne', | ||
'requestThree' : 'argTwo' | ||
}); | ||
}); | ||
it('should call the set of requests', function() { | ||
expect(this.Requests.request) | ||
.to.have.callCount(5) | ||
.and.calledWith('requestOne', 'argOne') | ||
.and.calledWith('requestTwo', 'argOne') | ||
.and.calledWith('requestThree', 'argTwo'); | ||
}); | ||
it('should return an array of replies', function() { | ||
expect(this.Requests.request) | ||
.to.have.returned(['replyOne', 'replyTwo', 'replyThree']); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
125406
2274