diff --git a/CHANGELOG.md b/CHANGELOG.md index 94d0861..1a5b562 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Change log +### v1.2.0 + * Adds Radio, allowing you to create explicit namespaces called Channels. A Channel is made up of + an instance of each of the three messaging systems. + ### v1.1.0 - * Removes the Error on unhandled commands/requests + * Removes the Error on unhandled commands/requests ### v1.0.1 * update dependencies diff --git a/bower.json b/bower.json index 4389caa..7b634b6 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "backbone.wreqr", - "version": "1.1.0", + "version": "1.2.0", "homepage": "https://github.com/marionettejs/backbone.wreqr", "authors": [ "Derick Bailey" diff --git a/component.json b/component.json index 71c187f..8d5ea82 100644 --- a/component.json +++ b/component.json @@ -1,7 +1,7 @@ { "name": "backbone.wreqr", "description": "A Simple Service Bus For Backbone and Backbone.Marionette", - "version": "1.1.0", + "version": "1.2.0", "repo": "marionettejs/backbone.wreqr", "keywords": [ "backbone", diff --git a/lib/amd/backbone.wreqr.js b/lib/amd/backbone.wreqr.js index 90af1eb..9d89e4d 100644 --- a/lib/amd/backbone.wreqr.js +++ b/lib/amd/backbone.wreqr.js @@ -268,6 +268,154 @@ Wreqr.EventAggregator = (function(Backbone, _){ return EA; })(Backbone, _); + // Wreqr.Channel +// -------------- +// +// An object that wraps the three messaging systems: +// EventAggregator, RequestResponse, Commands +Wreqr.Channel = (function(Wreqr){ + "use strict"; + + var Channel = function(channelName) { + this.vent = new Backbone.Wreqr.EventAggregator(); + this.reqres = new Backbone.Wreqr.RequestResponse(); + this.commands = new Backbone.Wreqr.Commands(); + this.channelName = channelName; + }; + + _.extend(Channel.prototype, { + + // Remove all handlers from the messaging systems of this channel + reset: function() { + this.vent.off(); + this.vent.stopListening(); + this.reqres.removeAllHandlers(); + this.commands.removeAllHandlers(); + return this; + }, + + // Connect a hash of events; one for each messaging system + connectEvents: function(hash, context) { + this._connect('vent', hash, context); + return this; + }, + + connectCommands: function(hash, context) { + this._connect('commands', hash, context); + return this; + }, + + connectRequests: function(hash, context) { + this._connect('reqres', hash, context); + return this; + }, + + // Attach the handlers to a given message system `type` + _connect: function(type, hash, context) { + if (!hash) { + return; + } + + context = context || this; + var method = (type === 'vent') ? 'on' : 'setHandler'; + + _.each(hash, function(fn, eventName) { + this[type][method](eventName, _.bind(fn, context)); + }, this); + } + }); + + + return Channel; +})(Wreqr); + + // Wreqr.Radio +// -------------- +// +// An object that lets you communicate with many channels. +Wreqr.radio = (function(Wreqr){ + "use strict"; + + var Radio = function() { + this._channels = {}; + this.vent = {}; + this.commands = {}; + this.reqres = {}; + this._proxyMethods(); + }; + + _.extend(Radio.prototype, { + + channel: function(channelName) { + if (!channelName) { + throw new Error('Channel must receive a name'); + } + + return this._getChannel( channelName ); + }, + + _getChannel: function(channelName) { + var channel = this._channels[channelName]; + + if(!channel) { + channel = new Wreqr.Channel(channelName); + this._channels[channelName] = channel; + } + + return channel; + }, + + _proxyMethods: function() { + _.each(['vent', 'commands', 'reqres'], function(system) { + _.each( messageSystems[system], function(method) { + this[system][method] = proxyMethod(this, system, method); + }, this); + }, this); + } + }); + + + var messageSystems = { + vent: [ + 'on', + 'off', + 'trigger', + 'once', + 'stopListening', + 'listenTo', + 'listenToOnce' + ], + + commands: [ + 'execute', + 'setHandler', + 'setHandlers', + 'removeHandler', + 'removeAllHandlers' + ], + + reqres: [ + 'request', + 'setHandler', + 'setHandlers', + 'removeHandler', + 'removeAllHandlers' + ] + }; + + var proxyMethod = function(radio, system, method) { + return function(channelName) { + var messageSystem = radio._getChannel(channelName)[system]; + var args = Array.prototype.slice.call(arguments, 1); + + messageSystem[method].apply(messageSystem, args); + }; + }; + + return new Radio(); + +})(Wreqr); + return Wreqr; })(Backbone, Backbone.Marionette, _); diff --git a/lib/amd/backbone.wreqr.min.js b/lib/amd/backbone.wreqr.min.js index 428feab..0bdfac6 100644 --- a/lib/amd/backbone.wreqr.min.js +++ b/lib/amd/backbone.wreqr.min.js @@ -8,4 +8,4 @@ // http://github.com/marionettejs/backbone.wreqr -(function(t,e){if("object"==typeof exports){var n=require("underscore"),r=require("backbone");module.exports=e(n,r)}else"function"==typeof define&&define.amd&&define(["underscore","backbone"],e)})(this,function(t,e){"use strict";return e.Wreqr=function(t,e,n){var r={};return r.Handlers=function(t,e){var n=function(t){this.options=t,this._wreqrHandlers={},e.isFunction(this.initialize)&&this.initialize(t)};return n.extend=t.Model.extend,e.extend(n.prototype,t.Events,{setHandlers:function(t){e.each(t,function(t,n){var r=null;e.isObject(t)&&!e.isFunction(t)&&(r=t.context,t=t.callback),this.setHandler(n,t,r)},this)},setHandler:function(t,e,n){var r={callback:e,context:n};this._wreqrHandlers[t]=r,this.trigger("handler:add",t,e,n)},hasHandler:function(t){return!!this._wreqrHandlers[t]},getHandler:function(t){var e=this._wreqrHandlers[t];if(e)return function(){var t=Array.prototype.slice.apply(arguments);return e.callback.apply(e.context,t)}},removeHandler:function(t){delete this._wreqrHandlers[t]},removeAllHandlers:function(){this._wreqrHandlers={}}}),n}(t,n),r.CommandStorage=function(){var e=function(t){this.options=t,this._commands={},n.isFunction(this.initialize)&&this.initialize(t)};return n.extend(e.prototype,t.Events,{getCommands:function(t){var e=this._commands[t];return e||(e={command:t,instances:[]},this._commands[t]=e),e},addCommand:function(t,e){var n=this.getCommands(t);n.instances.push(e)},clearCommands:function(t){var e=this.getCommands(t);e.instances=[]}}),e}(),r.Commands=function(t){return t.Handlers.extend({storageType:t.CommandStorage,constructor:function(e){this.options=e||{},this._initializeStorage(this.options),this.on("handler:add",this._executeCommands,this);var n=Array.prototype.slice.call(arguments);t.Handlers.prototype.constructor.apply(this,n)},execute:function(t,e){t=arguments[0],e=Array.prototype.slice.call(arguments,1),this.hasHandler(t)?this.getHandler(t).apply(this,e):this.storage.addCommand(t,e)},_executeCommands:function(t,e,r){var i=this.storage.getCommands(t);n.each(i.instances,function(t){e.apply(r,t)}),this.storage.clearCommands(t)},_initializeStorage:function(t){var e,r=t.storageType||this.storageType;e=n.isFunction(r)?new r:r,this.storage=e}})}(r),r.RequestResponse=function(t){return t.Handlers.extend({request:function(){var t=arguments[0],e=Array.prototype.slice.call(arguments,1);return this.hasHandler(t)?this.getHandler(t).apply(this,e):void 0}})}(r),r.EventAggregator=function(t,e){var n=function(){};return n.extend=t.Model.extend,e.extend(n.prototype,t.Events),n}(t,n),r}(e,e.Marionette,t),e.Wreqr}); \ No newline at end of file +(function(e,n){if("object"==typeof exports){var t=require("underscore"),r=require("backbone");module.exports=n(t,r)}else"function"==typeof define&&define.amd&&define(["underscore","backbone"],n)})(this,function(e,n){"use strict";return n.Wreqr=function(e,n,t){var r={};return r.Handlers=function(e,n){var t=function(e){this.options=e,this._wreqrHandlers={},n.isFunction(this.initialize)&&this.initialize(e)};return t.extend=e.Model.extend,n.extend(t.prototype,e.Events,{setHandlers:function(e){n.each(e,function(e,t){var r=null;n.isObject(e)&&!n.isFunction(e)&&(r=e.context,e=e.callback),this.setHandler(t,e,r)},this)},setHandler:function(e,n,t){var r={callback:n,context:t};this._wreqrHandlers[e]=r,this.trigger("handler:add",e,n,t)},hasHandler:function(e){return!!this._wreqrHandlers[e]},getHandler:function(e){var n=this._wreqrHandlers[e];if(n)return function(){var e=Array.prototype.slice.apply(arguments);return n.callback.apply(n.context,e)}},removeHandler:function(e){delete this._wreqrHandlers[e]},removeAllHandlers:function(){this._wreqrHandlers={}}}),t}(e,t),r.CommandStorage=function(){var n=function(e){this.options=e,this._commands={},t.isFunction(this.initialize)&&this.initialize(e)};return t.extend(n.prototype,e.Events,{getCommands:function(e){var n=this._commands[e];return n||(n={command:e,instances:[]},this._commands[e]=n),n},addCommand:function(e,n){var t=this.getCommands(e);t.instances.push(n)},clearCommands:function(e){var n=this.getCommands(e);n.instances=[]}}),n}(),r.Commands=function(e){return e.Handlers.extend({storageType:e.CommandStorage,constructor:function(n){this.options=n||{},this._initializeStorage(this.options),this.on("handler:add",this._executeCommands,this);var t=Array.prototype.slice.call(arguments);e.Handlers.prototype.constructor.apply(this,t)},execute:function(e,n){e=arguments[0],n=Array.prototype.slice.call(arguments,1),this.hasHandler(e)?this.getHandler(e).apply(this,n):this.storage.addCommand(e,n)},_executeCommands:function(e,n,r){var s=this.storage.getCommands(e);t.each(s.instances,function(e){n.apply(r,e)}),this.storage.clearCommands(e)},_initializeStorage:function(e){var n,r=e.storageType||this.storageType;n=t.isFunction(r)?new r:r,this.storage=n}})}(r),r.RequestResponse=function(e){return e.Handlers.extend({request:function(){var e=arguments[0],n=Array.prototype.slice.call(arguments,1);return this.hasHandler(e)?this.getHandler(e).apply(this,n):void 0}})}(r),r.EventAggregator=function(e,n){var t=function(){};return t.extend=e.Model.extend,n.extend(t.prototype,e.Events),t}(e,t),r.Channel=function(){var n=function(n){this.vent=new e.Wreqr.EventAggregator,this.reqres=new e.Wreqr.RequestResponse,this.commands=new e.Wreqr.Commands,this.channelName=n};return t.extend(n.prototype,{reset:function(){return this.vent.off(),this.vent.stopListening(),this.reqres.removeAllHandlers(),this.commands.removeAllHandlers(),this},connectEvents:function(e,n){return this._connect("vent",e,n),this},connectCommands:function(e,n){return this._connect("commands",e,n),this},connectRequests:function(e,n){return this._connect("reqres",e,n),this},_connect:function(e,n,r){if(n){r=r||this;var s="vent"===e?"on":"setHandler";t.each(n,function(n,i){this[e][s](i,t.bind(n,r))},this)}}}),n}(r),r.radio=function(e){var n=function(){this._channels={},this.vent={},this.commands={},this.reqres={},this._proxyMethods()};t.extend(n.prototype,{channel:function(e){if(!e)throw Error("Channel must receive a name");return this._getChannel(e)},_getChannel:function(n){var t=this._channels[n];return t||(t=new e.Channel(n),this._channels[n]=t),t},_proxyMethods:function(){t.each(["vent","commands","reqres"],function(e){t.each(r[e],function(n){this[e][n]=s(this,e,n)},this)},this)}});var r={vent:["on","off","trigger","once","stopListening","listenTo","listenToOnce"],commands:["execute","setHandler","setHandlers","removeHandler","removeAllHandlers"],reqres:["request","setHandler","setHandlers","removeHandler","removeAllHandlers"]},s=function(e,n,t){return function(r){var s=e._getChannel(r)[n],i=Array.prototype.slice.call(arguments,1);s[t].apply(s,i)}};return new n}(r),r}(n,n.Marionette,e),n.Wreqr}); \ No newline at end of file diff --git a/lib/backbone.wreqr.js b/lib/backbone.wreqr.js index f2df859..74af8a5 100644 --- a/lib/backbone.wreqr.js +++ b/lib/backbone.wreqr.js @@ -262,6 +262,154 @@ Wreqr.EventAggregator = (function(Backbone, _){ return EA; })(Backbone, _); + // Wreqr.Channel +// -------------- +// +// An object that wraps the three messaging systems: +// EventAggregator, RequestResponse, Commands +Wreqr.Channel = (function(Wreqr){ + "use strict"; + + var Channel = function(channelName) { + this.vent = new Backbone.Wreqr.EventAggregator(); + this.reqres = new Backbone.Wreqr.RequestResponse(); + this.commands = new Backbone.Wreqr.Commands(); + this.channelName = channelName; + }; + + _.extend(Channel.prototype, { + + // Remove all handlers from the messaging systems of this channel + reset: function() { + this.vent.off(); + this.vent.stopListening(); + this.reqres.removeAllHandlers(); + this.commands.removeAllHandlers(); + return this; + }, + + // Connect a hash of events; one for each messaging system + connectEvents: function(hash, context) { + this._connect('vent', hash, context); + return this; + }, + + connectCommands: function(hash, context) { + this._connect('commands', hash, context); + return this; + }, + + connectRequests: function(hash, context) { + this._connect('reqres', hash, context); + return this; + }, + + // Attach the handlers to a given message system `type` + _connect: function(type, hash, context) { + if (!hash) { + return; + } + + context = context || this; + var method = (type === 'vent') ? 'on' : 'setHandler'; + + _.each(hash, function(fn, eventName) { + this[type][method](eventName, _.bind(fn, context)); + }, this); + } + }); + + + return Channel; +})(Wreqr); + + // Wreqr.Radio +// -------------- +// +// An object that lets you communicate with many channels. +Wreqr.radio = (function(Wreqr){ + "use strict"; + + var Radio = function() { + this._channels = {}; + this.vent = {}; + this.commands = {}; + this.reqres = {}; + this._proxyMethods(); + }; + + _.extend(Radio.prototype, { + + channel: function(channelName) { + if (!channelName) { + throw new Error('Channel must receive a name'); + } + + return this._getChannel( channelName ); + }, + + _getChannel: function(channelName) { + var channel = this._channels[channelName]; + + if(!channel) { + channel = new Wreqr.Channel(channelName); + this._channels[channelName] = channel; + } + + return channel; + }, + + _proxyMethods: function() { + _.each(['vent', 'commands', 'reqres'], function(system) { + _.each( messageSystems[system], function(method) { + this[system][method] = proxyMethod(this, system, method); + }, this); + }, this); + } + }); + + + var messageSystems = { + vent: [ + 'on', + 'off', + 'trigger', + 'once', + 'stopListening', + 'listenTo', + 'listenToOnce' + ], + + commands: [ + 'execute', + 'setHandler', + 'setHandlers', + 'removeHandler', + 'removeAllHandlers' + ], + + reqres: [ + 'request', + 'setHandler', + 'setHandlers', + 'removeHandler', + 'removeAllHandlers' + ] + }; + + var proxyMethod = function(radio, system, method) { + return function(channelName) { + var messageSystem = radio._getChannel(channelName)[system]; + var args = Array.prototype.slice.call(arguments, 1); + + messageSystem[method].apply(messageSystem, args); + }; + }; + + return new Radio(); + +})(Wreqr); + return Wreqr; })(Backbone, Backbone.Marionette, _); diff --git a/lib/backbone.wreqr.map b/lib/backbone.wreqr.map index a54c82a..ebbd87f 100644 --- a/lib/backbone.wreqr.map +++ b/lib/backbone.wreqr.map @@ -1 +1 @@ -{"version":3,"file":"lib/backbone.wreqr.min.js","sources":["?"],"names":["Backbone","Wreqr","Marionette","_","Handlers","options","this","_wreqrHandlers","isFunction","initialize","extend","Model","prototype","Events","setHandlers","handlers","each","handler","name","context","isObject","callback","setHandler","config","trigger","hasHandler","getHandler","args","Array","slice","apply","arguments","removeHandler","removeAllHandlers","CommandStorage","_commands","getCommands","commandName","commands","command","instances","addCommand","push","clearCommands","Commands","storageType","constructor","_initializeStorage","on","_executeCommands","call","execute","storage","StorageType","RequestResponse","request","EventAggregator","EA"],"mappings":"AAUAA,SAASC,MAAQ,SAAUD,EAAUE,EAAYC,GAC/C,YACA,IAAIF,KA6PJ,OAvPFA,GAAMG,SAAW,SAAUJ,EAAUG,GAMnC,GAAIC,GAAW,SAASC,GACtBC,KAAKD,QAAUA,EACfC,KAAKC,kBAEDJ,EAAEK,WAAW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,WAMH1B,GAOHA,EAAMuD,gBAAkB,SAAUxD,EAAUG,GAE1C,GAAIsD,GAAK,YAQT,OALAA,GAAG/C,OAASV,EAASW,MAAMD,OAG3BP,EAAEO,OAAO+C,EAAG7C,UAAWZ,EAASa,QAEzB4C,GACNzD,EAAUG,GAGJF,GACND,SAAUA,SAASE,WAAYC"} \ No newline at end of file +{"version":3,"file":"lib/backbone.wreqr.min.js","sources":["?"],"names":["Backbone","Wreqr","Marionette","_","Handlers","options","this","_wreqrHandlers","isFunction","initialize","extend","Model","prototype","Events","setHandlers","handlers","each","handler","name","context","isObject","callback","setHandler","config","trigger","hasHandler","getHandler","args","Array","slice","apply","arguments","removeHandler","removeAllHandlers","CommandStorage","_commands","getCommands","commandName","commands","command","instances","addCommand","push","clearCommands","Commands","storageType","constructor","_initializeStorage","on","_executeCommands","call","execute","storage","StorageType","RequestResponse","request","EventAggregator","EA","Channel","channelName","vent","reqres","reset","off","stopListening","connectEvents","hash","_connect","connectCommands","connectRequests","type","method","fn","eventName","bind","radio","Radio","_channels","_proxyMethods","channel","Error","_getChannel","system","messageSystems","proxyMethod","messageSystem"],"mappings":"AAUAA,SAASC,MAAQ,SAAUD,EAAUE,EAAYC,GAC/C,YACA,IAAIF,KAiZJ,OA3YFA,GAAMG,SAAW,SAAUJ,EAAUG,GAMnC,GAAIC,GAAW,SAASC,GACtBC,KAAKD,QAAUA,EACfC,KAAKC,kBAEDJ,EAAEK,WAAWF,KAAKG,aACpBH,KAAKG,WAAWJ,GAsEpB,OAlEAD,GAASM,OAASV,EAASW,MAAMD,OAKjCP,EAAEO,OAAON,EAASQ,UAAWZ,EAASa,QAGpCC,YAAa,SAASC,GACpBZ,EAAEa,KAAKD,EAAU,SAASE,EAASC,GACjC,GAAIC,GAAU,IAEVhB,GAAEiB,SAASH,KAAad,EAAEK,WAAWS,KACvCE,EAAUF,EAAQE,QAClBF,EAAUA,EAAQI,UAGpBf,KAAKgB,WAAWJ,EAAMD,EAASE,IAC9Bb,O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ACvCjE,KAAK4E,GAAQX,GAAUa,EAAY9E,KAAM4E,EAAQX,IAChDjE,OACFA,QAKP,IAAI6E,IACFvB,MACE,KACA,MACA,UACA,OACA,gBACA,WACA,gBAGFtB,UACE,UACA,aACA,cACA,gBACA,qBAGFuB,QACE,UACA,aACA,cACA,gBACA,sBAIAuB,EAAc,SAAST,EAAOO,EAAQX,GACxC,MAAO,UAASZ,GACd,GAAI0B,GAAgBV,EAAMM,YAAYtB,GAAauB,GAC/CvD,EAAOC,MAAMhB,UAAUiB,MAAMqB,KAAKnB,UAAW,EAEjDsD,GAAcd,GAAQzC,MAAMuD,EAAe1D,IAI/C,OAAO,IAAIiD,IAEV3E,GAGMA,GACND,SAAUA,SAASE,WAAYC"} \ No newline at end of file diff --git a/lib/backbone.wreqr.min.js b/lib/backbone.wreqr.min.js index fba9380..ddf7752 100644 --- a/lib/backbone.wreqr.min.js +++ b/lib/backbone.wreqr.min.js @@ -8,5 +8,5 @@ // http://github.com/marionettejs/backbone.wreqr -Backbone.Wreqr=function(t,e,n){"use strict";var r={};return r.Handlers=function(t,e){var n=function(t){this.options=t,this._wreqrHandlers={},e.isFunction(this.initialize)&&this.initialize(t)};return n.extend=t.Model.extend,e.extend(n.prototype,t.Events,{setHandlers:function(t){e.each(t,function(t,n){var r=null;e.isObject(t)&&!e.isFunction(t)&&(r=t.context,t=t.callback),this.setHandler(n,t,r)},this)},setHandler:function(t,e,n){var r={callback:e,context:n};this._wreqrHandlers[t]=r,this.trigger("handler:add",t,e,n)},hasHandler:function(t){return!!this._wreqrHandlers[t]},getHandler:function(t){var e=this._wreqrHandlers[t];if(e)return function(){var t=Array.prototype.slice.apply(arguments);return e.callback.apply(e.context,t)}},removeHandler:function(t){delete this._wreqrHandlers[t]},removeAllHandlers:function(){this._wreqrHandlers={}}}),n}(t,n),r.CommandStorage=function(){var e=function(t){this.options=t,this._commands={},n.isFunction(this.initialize)&&this.initialize(t)};return n.extend(e.prototype,t.Events,{getCommands:function(t){var e=this._commands[t];return e||(e={command:t,instances:[]},this._commands[t]=e),e},addCommand:function(t,e){var n=this.getCommands(t);n.instances.push(e)},clearCommands:function(t){var e=this.getCommands(t);e.instances=[]}}),e}(),r.Commands=function(t){return t.Handlers.extend({storageType:t.CommandStorage,constructor:function(e){this.options=e||{},this._initializeStorage(this.options),this.on("handler:add",this._executeCommands,this);var n=Array.prototype.slice.call(arguments);t.Handlers.prototype.constructor.apply(this,n)},execute:function(t,e){t=arguments[0],e=Array.prototype.slice.call(arguments,1),this.hasHandler(t)?this.getHandler(t).apply(this,e):this.storage.addCommand(t,e)},_executeCommands:function(t,e,r){var i=this.storage.getCommands(t);n.each(i.instances,function(t){e.apply(r,t)}),this.storage.clearCommands(t)},_initializeStorage:function(t){var e,r=t.storageType||this.storageType;e=n.isFunction(r)?new r:r,this.storage=e}})}(r),r.RequestResponse=function(t){return t.Handlers.extend({request:function(){var t=arguments[0],e=Array.prototype.slice.call(arguments,1);return this.hasHandler(t)?this.getHandler(t).apply(this,e):void 0}})}(r),r.EventAggregator=function(t,e){var n=function(){};return n.extend=t.Model.extend,e.extend(n.prototype,t.Events),n}(t,n),r}(Backbone,Backbone.Marionette,_); +Backbone.Wreqr=function(e,n,t){"use strict";var r={};return r.Handlers=function(e,n){var t=function(e){this.options=e,this._wreqrHandlers={},n.isFunction(this.initialize)&&this.initialize(e)};return t.extend=e.Model.extend,n.extend(t.prototype,e.Events,{setHandlers:function(e){n.each(e,function(e,t){var r=null;n.isObject(e)&&!n.isFunction(e)&&(r=e.context,e=e.callback),this.setHandler(t,e,r)},this)},setHandler:function(e,n,t){var r={callback:n,context:t};this._wreqrHandlers[e]=r,this.trigger("handler:add",e,n,t)},hasHandler:function(e){return!!this._wreqrHandlers[e]},getHandler:function(e){var n=this._wreqrHandlers[e];if(n)return function(){var e=Array.prototype.slice.apply(arguments);return n.callback.apply(n.context,e)}},removeHandler:function(e){delete this._wreqrHandlers[e]},removeAllHandlers:function(){this._wreqrHandlers={}}}),t}(e,t),r.CommandStorage=function(){var n=function(e){this.options=e,this._commands={},t.isFunction(this.initialize)&&this.initialize(e)};return t.extend(n.prototype,e.Events,{getCommands:function(e){var n=this._commands[e];return n||(n={command:e,instances:[]},this._commands[e]=n),n},addCommand:function(e,n){var t=this.getCommands(e);t.instances.push(n)},clearCommands:function(e){var n=this.getCommands(e);n.instances=[]}}),n}(),r.Commands=function(e){return e.Handlers.extend({storageType:e.CommandStorage,constructor:function(n){this.options=n||{},this._initializeStorage(this.options),this.on("handler:add",this._executeCommands,this);var t=Array.prototype.slice.call(arguments);e.Handlers.prototype.constructor.apply(this,t)},execute:function(e,n){e=arguments[0],n=Array.prototype.slice.call(arguments,1),this.hasHandler(e)?this.getHandler(e).apply(this,n):this.storage.addCommand(e,n)},_executeCommands:function(e,n,r){var s=this.storage.getCommands(e);t.each(s.instances,function(e){n.apply(r,e)}),this.storage.clearCommands(e)},_initializeStorage:function(e){var n,r=e.storageType||this.storageType;n=t.isFunction(r)?new r:r,this.storage=n}})}(r),r.RequestResponse=function(e){return e.Handlers.extend({request:function(){var e=arguments[0],n=Array.prototype.slice.call(arguments,1);return this.hasHandler(e)?this.getHandler(e).apply(this,n):void 0}})}(r),r.EventAggregator=function(e,n){var t=function(){};return t.extend=e.Model.extend,n.extend(t.prototype,e.Events),t}(e,t),r.Channel=function(){var n=function(n){this.vent=new e.Wreqr.EventAggregator,this.reqres=new e.Wreqr.RequestResponse,this.commands=new e.Wreqr.Commands,this.channelName=n};return t.extend(n.prototype,{reset:function(){return this.vent.off(),this.vent.stopListening(),this.reqres.removeAllHandlers(),this.commands.removeAllHandlers(),this},connectEvents:function(e,n){return this._connect("vent",e,n),this},connectCommands:function(e,n){return this._connect("commands",e,n),this},connectRequests:function(e,n){return this._connect("reqres",e,n),this},_connect:function(e,n,r){if(n){r=r||this;var s="vent"===e?"on":"setHandler";t.each(n,function(n,i){this[e][s](i,t.bind(n,r))},this)}}}),n}(r),r.radio=function(e){var n=function(){this._channels={},this.vent={},this.commands={},this.reqres={},this._proxyMethods()};t.extend(n.prototype,{channel:function(e){if(!e)throw Error("Channel must receive a name");return this._getChannel(e)},_getChannel:function(n){var t=this._channels[n];return t||(t=new e.Channel(n),this._channels[n]=t),t},_proxyMethods:function(){t.each(["vent","commands","reqres"],function(e){t.each(r[e],function(n){this[e][n]=s(this,e,n)},this)},this)}});var r={vent:["on","off","trigger","once","stopListening","listenTo","listenToOnce"],commands:["execute","setHandler","setHandlers","removeHandler","removeAllHandlers"],reqres:["request","setHandler","setHandlers","removeHandler","removeAllHandlers"]},s=function(e,n,t){return function(r){var s=e._getChannel(r)[n],i=Array.prototype.slice.call(arguments,1);s[t].apply(s,i)}};return new n}(r),r}(Backbone,Backbone.Marionette,_); //@ sourceMappingURL=backbone.wreqr.map \ No newline at end of file diff --git a/package.json b/package.json index 87c8bdb..94b7e00 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "backbone.wreqr", "description": "A Simple Service Bus For Backbone and Backbone.Marionette", - "version": "1.1.0", + "version": "1.2.0", "homepage": "https://github.com/marionettejs/backbone.wreqr", "main": "lib/amd/backbone.wreqr.js", "keywords": [ diff --git a/reports/coverage.json b/reports/coverage.json index 4f1347b..0683068 100644 --- a/reports/coverage.json +++ b/reports/coverage.json @@ -1 +1 @@ -{"./src/wreqr.js":{"path":"./src/wreqr.js","s":{"1":1,"2":1,"3":1},"b":{},"f":{"1":1},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":51}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":12,"column":37}},"2":{"start":{"line":3,"column":2},"end":{"line":3,"column":17}},"3":{"start":{"line":11,"column":2},"end":{"line":11,"column":15}}},"branchMap":{}},"./spec/javascripts/support/wreqrHelper.js":{"path":"./spec/javascripts/support/wreqrHelper.js","s":{"1":1,"2":1},"b":{},"f":{"1":1},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":17}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":3,"column":9}},"2":{"start":{"line":2,"column":2},"end":{"line":2,"column":32}}},"branchMap":{}},"./src/wreqr.handlers.js":{"path":"./src/wreqr.handlers.js","s":{"1":1,"2":1,"3":22,"4":22,"5":22,"6":0,"7":1,"8":1,"9":3,"10":5,"11":5,"12":1,"13":1,"14":5,"15":19,"16":19,"17":19,"18":11,"19":16,"20":16,"21":4,"22":12,"23":12,"24":12,"25":1,"26":1,"27":1},"b":{"1":[0,22],"2":[1,4],"3":[5,5],"4":[4,12]},"f":{"1":1,"2":22,"3":3,"4":5,"5":19,"6":11,"7":16,"8":12,"9":1,"10":1},"fnMap":{"1":{"name":"(anonymous_1)","line":5,"loc":{"start":{"line":5,"column":18},"end":{"line":5,"column":39}}},"2":{"name":"(anonymous_2)","line":11,"loc":{"start":{"line":11,"column":17},"end":{"line":11,"column":34}}},"3":{"name":"(anonymous_3)","line":28,"loc":{"start":{"line":28,"column":17},"end":{"line":28,"column":35}}},"4":{"name":"(anonymous_4)","line":29,"loc":{"start":{"line":29,"column":23},"end":{"line":29,"column":46}}},"5":{"name":"(anonymous_5)","line":43,"loc":{"start":{"line":43,"column":16},"end":{"line":43,"column":48}}},"6":{"name":"(anonymous_6)","line":55,"loc":{"start":{"line":55,"column":16},"end":{"line":55,"column":30}}},"7":{"name":"(anonymous_7)","line":62,"loc":{"start":{"line":62,"column":16},"end":{"line":62,"column":30}}},"8":{"name":"(anonymous_8)","line":69,"loc":{"start":{"line":69,"column":13},"end":{"line":69,"column":23}}},"9":{"name":"(anonymous_9)","line":76,"loc":{"start":{"line":76,"column":19},"end":{"line":76,"column":33}}},"10":{"name":"(anonymous_10)","line":81,"loc":{"start":{"line":81,"column":23},"end":{"line":81,"column":33}}}},"statementMap":{"1":{"start":{"line":5,"column":0},"end":{"line":87,"column":16}},"2":{"start":{"line":11,"column":2},"end":{"line":18,"column":4}},"3":{"start":{"line":12,"column":4},"end":{"line":12,"column":27}},"4":{"start":{"line":13,"column":4},"end":{"line":13,"column":29}},"5":{"start":{"line":15,"column":4},"end":{"line":17,"column":5}},"6":{"start":{"line":16,"column":6},"end":{"line":16,"column":31}},"7":{"start":{"line":20,"column":2},"end":{"line":20,"column":42}},"8":{"start":{"line":25,"column":2},"end":{"line":84,"column":5}},"9":{"start":{"line":29,"column":6},"end":{"line":38,"column":15}},"10":{"start":{"line":30,"column":8},"end":{"line":30,"column":27}},"11":{"start":{"line":32,"column":8},"end":{"line":35,"column":9}},"12":{"start":{"line":33,"column":10},"end":{"line":33,"column":36}},"13":{"start":{"line":34,"column":10},"end":{"line":34,"column":37}},"14":{"start":{"line":37,"column":8},"end":{"line":37,"column":48}},"15":{"start":{"line":44,"column":6},"end":{"line":47,"column":8}},"16":{"start":{"line":49,"column":6},"end":{"line":49,"column":41}},"17":{"start":{"line":51,"column":6},"end":{"line":51,"column":58}},"18":{"start":{"line":56,"column":6},"end":{"line":56,"column":42}},"19":{"start":{"line":63,"column":6},"end":{"line":63,"column":45}},"20":{"start":{"line":65,"column":6},"end":{"line":67,"column":7}},"21":{"start":{"line":66,"column":8},"end":{"line":66,"column":15}},"22":{"start":{"line":69,"column":6},"end":{"line":72,"column":8}},"23":{"start":{"line":70,"column":8},"end":{"line":70,"column":58}},"24":{"start":{"line":71,"column":8},"end":{"line":71,"column":59}},"25":{"start":{"line":77,"column":6},"end":{"line":77,"column":39}},"26":{"start":{"line":82,"column":6},"end":{"line":82,"column":31}},"27":{"start":{"line":86,"column":2},"end":{"line":86,"column":18}}},"branchMap":{"1":{"line":15,"type":"if","locations":[{"start":{"line":15,"column":4},"end":{"line":15,"column":4}},{"start":{"line":15,"column":4},"end":{"line":15,"column":4}}]},"2":{"line":32,"type":"if","locations":[{"start":{"line":32,"column":8},"end":{"line":32,"column":8}},{"start":{"line":32,"column":8},"end":{"line":32,"column":8}}]},"3":{"line":32,"type":"binary-expr","locations":[{"start":{"line":32,"column":12},"end":{"line":32,"column":31}},{"start":{"line":32,"column":35},"end":{"line":32,"column":57}}]},"4":{"line":65,"type":"if","locations":[{"start":{"line":65,"column":6},"end":{"line":65,"column":6}},{"start":{"line":65,"column":6},"end":{"line":65,"column":6}}]}}},"./src/wreqr.commandStorage.js":{"path":"./src/wreqr.commandStorage.js","s":{"1":1,"2":1,"3":6,"4":6,"5":6,"6":0,"7":1,"8":15,"9":15,"10":6,"11":6,"12":15,"13":3,"14":3,"15":5,"16":5,"17":1},"b":{"1":[0,6],"2":[6,9]},"f":{"1":1,"2":6,"3":15,"4":3,"5":5},"fnMap":{"1":{"name":"(anonymous_1)","line":5,"loc":{"start":{"line":5,"column":24},"end":{"line":5,"column":34}}},"2":{"name":"(anonymous_2)","line":9,"loc":{"start":{"line":9,"column":23},"end":{"line":9,"column":40}}},"3":{"name":"(anonymous_3)","line":24,"loc":{"start":{"line":24,"column":17},"end":{"line":24,"column":38}}},"4":{"name":"(anonymous_4)","line":45,"loc":{"start":{"line":45,"column":16},"end":{"line":45,"column":43}}},"5":{"name":"(anonymous_5)","line":51,"loc":{"start":{"line":51,"column":19},"end":{"line":51,"column":40}}}},"statementMap":{"1":{"start":{"line":5,"column":0},"end":{"line":58,"column":5}},"2":{"start":{"line":9,"column":2},"end":{"line":16,"column":4}},"3":{"start":{"line":10,"column":4},"end":{"line":10,"column":27}},"4":{"start":{"line":11,"column":4},"end":{"line":11,"column":24}},"5":{"start":{"line":13,"column":4},"end":{"line":15,"column":5}},"6":{"start":{"line":14,"column":6},"end":{"line":14,"column":31}},"7":{"start":{"line":19,"column":2},"end":{"line":55,"column":5}},"8":{"start":{"line":25,"column":6},"end":{"line":25,"column":49}},"9":{"start":{"line":28,"column":6},"end":{"line":38,"column":7}},"10":{"start":{"line":31,"column":8},"end":{"line":34,"column":10}},"11":{"start":{"line":37,"column":8},"end":{"line":37,"column":47}},"12":{"start":{"line":40,"column":6},"end":{"line":40,"column":22}},"13":{"start":{"line":46,"column":6},"end":{"line":46,"column":50}},"14":{"start":{"line":47,"column":6},"end":{"line":47,"column":35}},"15":{"start":{"line":52,"column":6},"end":{"line":52,"column":50}},"16":{"start":{"line":53,"column":6},"end":{"line":53,"column":29}},"17":{"start":{"line":57,"column":2},"end":{"line":57,"column":24}}},"branchMap":{"1":{"line":13,"type":"if","locations":[{"start":{"line":13,"column":4},"end":{"line":13,"column":4}},{"start":{"line":13,"column":4},"end":{"line":13,"column":4}}]},"2":{"line":28,"type":"if","locations":[{"start":{"line":28,"column":6},"end":{"line":28,"column":6}},{"start":{"line":28,"column":6},"end":{"line":28,"column":6}}]}}},"./src/wreqr.commands.js":{"path":"./src/wreqr.commands.js","s":{"1":1,"2":1,"3":10,"4":10,"5":10,"6":10,"7":10,"8":6,"9":6,"10":6,"11":3,"12":3,"13":5,"14":5,"15":2,"16":5,"17":10,"18":10,"19":10,"20":8,"21":2,"22":10},"b":{"1":[10,8],"2":[3,3],"3":[10,8],"4":[8,2]},"f":{"1":1,"2":10,"3":6,"4":5,"5":2,"6":10},"fnMap":{"1":{"name":"(anonymous_1)","line":6,"loc":{"start":{"line":6,"column":18},"end":{"line":6,"column":33}}},"2":{"name":"(anonymous_2)","line":13,"loc":{"start":{"line":13,"column":17},"end":{"line":13,"column":34}}},"3":{"name":"(anonymous_3)","line":24,"loc":{"start":{"line":24,"column":13},"end":{"line":24,"column":33}}},"4":{"name":"(anonymous_4)","line":37,"loc":{"start":{"line":37,"column":22},"end":{"line":37,"column":54}}},"5":{"name":"(anonymous_5)","line":41,"loc":{"start":{"line":41,"column":32},"end":{"line":41,"column":46}}},"6":{"name":"(anonymous_6)","line":50,"loc":{"start":{"line":50,"column":24},"end":{"line":50,"column":41}}}},"statementMap":{"1":{"start":{"line":6,"column":0},"end":{"line":64,"column":10}},"2":{"start":{"line":9,"column":2},"end":{"line":62,"column":5}},"3":{"start":{"line":14,"column":6},"end":{"line":14,"column":35}},"4":{"start":{"line":16,"column":6},"end":{"line":16,"column":44}},"5":{"start":{"line":17,"column":6},"end":{"line":17,"column":58}},"6":{"start":{"line":19,"column":6},"end":{"line":19,"column":55}},"7":{"start":{"line":20,"column":6},"end":{"line":20,"column":61}},"8":{"start":{"line":25,"column":6},"end":{"line":25,"column":26}},"9":{"start":{"line":26,"column":6},"end":{"line":26,"column":54}},"10":{"start":{"line":28,"column":6},"end":{"line":32,"column":7}},"11":{"start":{"line":29,"column":8},"end":{"line":29,"column":48}},"12":{"start":{"line":31,"column":8},"end":{"line":31,"column":44}},"13":{"start":{"line":38,"column":6},"end":{"line":38,"column":51}},"14":{"start":{"line":41,"column":6},"end":{"line":43,"column":9}},"15":{"start":{"line":42,"column":8},"end":{"line":42,"column":37}},"16":{"start":{"line":45,"column":6},"end":{"line":45,"column":39}},"17":{"start":{"line":51,"column":6},"end":{"line":51,"column":18}},"18":{"start":{"line":53,"column":6},"end":{"line":53,"column":64}},"19":{"start":{"line":54,"column":6},"end":{"line":58,"column":7}},"20":{"start":{"line":55,"column":8},"end":{"line":55,"column":36}},"21":{"start":{"line":57,"column":8},"end":{"line":57,"column":30}},"22":{"start":{"line":60,"column":6},"end":{"line":60,"column":29}}},"branchMap":{"1":{"line":14,"type":"binary-expr","locations":[{"start":{"line":14,"column":21},"end":{"line":14,"column":28}},{"start":{"line":14,"column":32},"end":{"line":14,"column":34}}]},"2":{"line":28,"type":"if","locations":[{"start":{"line":28,"column":6},"end":{"line":28,"column":6}},{"start":{"line":28,"column":6},"end":{"line":28,"column":6}}]},"3":{"line":53,"type":"binary-expr","locations":[{"start":{"line":53,"column":24},"end":{"line":53,"column":43}},{"start":{"line":53,"column":47},"end":{"line":53,"column":63}}]},"4":{"line":54,"type":"if","locations":[{"start":{"line":54,"column":6},"end":{"line":54,"column":6}},{"start":{"line":54,"column":6},"end":{"line":54,"column":6}}]}}},"./src/wreqr.eventaggregator.js":{"path":"./src/wreqr.eventaggregator.js","s":{"1":1,"2":1,"3":1,"4":1,"5":1},"b":{},"f":{"1":1,"2":2},"fnMap":{"1":{"name":"(anonymous_1)","line":6,"loc":{"start":{"line":6,"column":25},"end":{"line":6,"column":46}}},"2":{"name":"(anonymous_2)","line":8,"loc":{"start":{"line":8,"column":11},"end":{"line":8,"column":21}}}},"statementMap":{"1":{"start":{"line":6,"column":0},"end":{"line":17,"column":16}},"2":{"start":{"line":8,"column":2},"end":{"line":8,"column":24}},"3":{"start":{"line":11,"column":2},"end":{"line":11,"column":36}},"4":{"start":{"line":14,"column":2},"end":{"line":14,"column":42}},"5":{"start":{"line":16,"column":2},"end":{"line":16,"column":12}}},"branchMap":{}},"./src/wreqr.requestresponse.js":{"path":"./src/wreqr.requestresponse.js","s":{"1":1,"2":1,"3":3,"4":3,"5":3,"6":3},"b":{"1":[3,0]},"f":{"1":1,"2":3},"fnMap":{"1":{"name":"(anonymous_1)","line":6,"loc":{"start":{"line":6,"column":25},"end":{"line":6,"column":40}}},"2":{"name":"(anonymous_2)","line":10,"loc":{"start":{"line":10,"column":13},"end":{"line":10,"column":23}}}},"statementMap":{"1":{"start":{"line":6,"column":0},"end":{"line":19,"column":10}},"2":{"start":{"line":9,"column":2},"end":{"line":17,"column":5}},"3":{"start":{"line":11,"column":6},"end":{"line":11,"column":30}},"4":{"start":{"line":12,"column":6},"end":{"line":12,"column":58}},"5":{"start":{"line":13,"column":6},"end":{"line":15,"column":7}},"6":{"start":{"line":14,"column":8},"end":{"line":14,"column":55}}},"branchMap":{"1":{"line":13,"type":"if","locations":[{"start":{"line":13,"column":6},"end":{"line":13,"column":6}},{"start":{"line":13,"column":6},"end":{"line":13,"column":6}}]}}}} \ No newline at end of file +{"./src/wreqr.js":{"path":"./src/wreqr.js","s":{"1":1,"2":1,"3":1},"b":{},"f":{"1":1},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":51}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":14,"column":37}},"2":{"start":{"line":3,"column":2},"end":{"line":3,"column":17}},"3":{"start":{"line":13,"column":2},"end":{"line":13,"column":15}}},"branchMap":{}},"./spec/javascripts/support/wreqrHelper.js":{"path":"./spec/javascripts/support/wreqrHelper.js","s":{"1":1,"2":1},"b":{},"f":{"1":1},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":17}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":3,"column":9}},"2":{"start":{"line":2,"column":2},"end":{"line":2,"column":32}}},"branchMap":{}},"./src/wreqr.handlers.js":{"path":"./src/wreqr.handlers.js","s":{"1":1,"2":1,"3":36,"4":36,"5":36,"6":0,"7":1,"8":1,"9":3,"10":5,"11":5,"12":1,"13":1,"14":5,"15":27,"16":27,"17":27,"18":11,"19":16,"20":16,"21":4,"22":12,"23":12,"24":12,"25":1,"26":17,"27":1},"b":{"1":[0,36],"2":[1,4],"3":[5,5],"4":[4,12]},"f":{"1":1,"2":36,"3":3,"4":5,"5":27,"6":11,"7":16,"8":12,"9":1,"10":17},"fnMap":{"1":{"name":"(anonymous_1)","line":5,"loc":{"start":{"line":5,"column":18},"end":{"line":5,"column":39}}},"2":{"name":"(anonymous_2)","line":11,"loc":{"start":{"line":11,"column":17},"end":{"line":11,"column":34}}},"3":{"name":"(anonymous_3)","line":28,"loc":{"start":{"line":28,"column":17},"end":{"line":28,"column":35}}},"4":{"name":"(anonymous_4)","line":29,"loc":{"start":{"line":29,"column":23},"end":{"line":29,"column":46}}},"5":{"name":"(anonymous_5)","line":43,"loc":{"start":{"line":43,"column":16},"end":{"line":43,"column":48}}},"6":{"name":"(anonymous_6)","line":55,"loc":{"start":{"line":55,"column":16},"end":{"line":55,"column":30}}},"7":{"name":"(anonymous_7)","line":62,"loc":{"start":{"line":62,"column":16},"end":{"line":62,"column":30}}},"8":{"name":"(anonymous_8)","line":69,"loc":{"start":{"line":69,"column":13},"end":{"line":69,"column":23}}},"9":{"name":"(anonymous_9)","line":76,"loc":{"start":{"line":76,"column":19},"end":{"line":76,"column":33}}},"10":{"name":"(anonymous_10)","line":81,"loc":{"start":{"line":81,"column":23},"end":{"line":81,"column":33}}}},"statementMap":{"1":{"start":{"line":5,"column":0},"end":{"line":87,"column":16}},"2":{"start":{"line":11,"column":2},"end":{"line":18,"column":4}},"3":{"start":{"line":12,"column":4},"end":{"line":12,"column":27}},"4":{"start":{"line":13,"column":4},"end":{"line":13,"column":29}},"5":{"start":{"line":15,"column":4},"end":{"line":17,"column":5}},"6":{"start":{"line":16,"column":6},"end":{"line":16,"column":31}},"7":{"start":{"line":20,"column":2},"end":{"line":20,"column":42}},"8":{"start":{"line":25,"column":2},"end":{"line":84,"column":5}},"9":{"start":{"line":29,"column":6},"end":{"line":38,"column":15}},"10":{"start":{"line":30,"column":8},"end":{"line":30,"column":27}},"11":{"start":{"line":32,"column":8},"end":{"line":35,"column":9}},"12":{"start":{"line":33,"column":10},"end":{"line":33,"column":36}},"13":{"start":{"line":34,"column":10},"end":{"line":34,"column":37}},"14":{"start":{"line":37,"column":8},"end":{"line":37,"column":48}},"15":{"start":{"line":44,"column":6},"end":{"line":47,"column":8}},"16":{"start":{"line":49,"column":6},"end":{"line":49,"column":41}},"17":{"start":{"line":51,"column":6},"end":{"line":51,"column":58}},"18":{"start":{"line":56,"column":6},"end":{"line":56,"column":42}},"19":{"start":{"line":63,"column":6},"end":{"line":63,"column":45}},"20":{"start":{"line":65,"column":6},"end":{"line":67,"column":7}},"21":{"start":{"line":66,"column":8},"end":{"line":66,"column":15}},"22":{"start":{"line":69,"column":6},"end":{"line":72,"column":8}},"23":{"start":{"line":70,"column":8},"end":{"line":70,"column":58}},"24":{"start":{"line":71,"column":8},"end":{"line":71,"column":59}},"25":{"start":{"line":77,"column":6},"end":{"line":77,"column":39}},"26":{"start":{"line":82,"column":6},"end":{"line":82,"column":31}},"27":{"start":{"line":86,"column":2},"end":{"line":86,"column":18}}},"branchMap":{"1":{"line":15,"type":"if","locations":[{"start":{"line":15,"column":4},"end":{"line":15,"column":4}},{"start":{"line":15,"column":4},"end":{"line":15,"column":4}}]},"2":{"line":32,"type":"if","locations":[{"start":{"line":32,"column":8},"end":{"line":32,"column":8}},{"start":{"line":32,"column":8},"end":{"line":32,"column":8}}]},"3":{"line":32,"type":"binary-expr","locations":[{"start":{"line":32,"column":12},"end":{"line":32,"column":31}},{"start":{"line":32,"column":35},"end":{"line":32,"column":57}}]},"4":{"line":65,"type":"if","locations":[{"start":{"line":65,"column":6},"end":{"line":65,"column":6}},{"start":{"line":65,"column":6},"end":{"line":65,"column":6}}]}}},"./src/wreqr.channel.js":{"path":"./src/wreqr.channel.js","s":{"1":1,"2":1,"3":7,"4":7,"5":7,"6":7,"7":1,"8":8,"9":8,"10":8,"11":8,"12":8,"13":2,"14":2,"15":2,"16":2,"17":2,"18":2,"19":6,"20":0,"21":6,"22":6,"23":6,"24":12,"25":1},"b":{"1":[0,6],"2":[6,6],"3":[2,4]},"f":{"1":1,"2":7,"3":8,"4":2,"5":2,"6":2,"7":6,"8":12},"fnMap":{"1":{"name":"(anonymous_1)","line":6,"loc":{"start":{"line":6,"column":17},"end":{"line":6,"column":32}}},"2":{"name":"(anonymous_2)","line":9,"loc":{"start":{"line":9,"column":16},"end":{"line":9,"column":38}}},"3":{"name":"(anonymous_3)","line":19,"loc":{"start":{"line":19,"column":11},"end":{"line":19,"column":22}}},"4":{"name":"(anonymous_4)","line":28,"loc":{"start":{"line":28,"column":19},"end":{"line":28,"column":43}}},"5":{"name":"(anonymous_5)","line":33,"loc":{"start":{"line":33,"column":21},"end":{"line":33,"column":45}}},"6":{"name":"(anonymous_6)","line":38,"loc":{"start":{"line":38,"column":21},"end":{"line":38,"column":45}}},"7":{"name":"(anonymous_7)","line":44,"loc":{"start":{"line":44,"column":14},"end":{"line":44,"column":44}}},"8":{"name":"(anonymous_8)","line":52,"loc":{"start":{"line":52,"column":19},"end":{"line":52,"column":43}}}},"statementMap":{"1":{"start":{"line":6,"column":0},"end":{"line":60,"column":10}},"2":{"start":{"line":9,"column":2},"end":{"line":14,"column":4}},"3":{"start":{"line":10,"column":4},"end":{"line":10,"column":60}},"4":{"start":{"line":11,"column":4},"end":{"line":11,"column":60}},"5":{"start":{"line":12,"column":4},"end":{"line":12,"column":53}},"6":{"start":{"line":13,"column":4},"end":{"line":13,"column":35}},"7":{"start":{"line":16,"column":2},"end":{"line":56,"column":5}},"8":{"start":{"line":20,"column":6},"end":{"line":20,"column":22}},"9":{"start":{"line":21,"column":6},"end":{"line":21,"column":32}},"10":{"start":{"line":22,"column":6},"end":{"line":22,"column":38}},"11":{"start":{"line":23,"column":6},"end":{"line":23,"column":40}},"12":{"start":{"line":24,"column":6},"end":{"line":24,"column":18}},"13":{"start":{"line":29,"column":6},"end":{"line":29,"column":43}},"14":{"start":{"line":30,"column":6},"end":{"line":30,"column":18}},"15":{"start":{"line":34,"column":6},"end":{"line":34,"column":47}},"16":{"start":{"line":35,"column":6},"end":{"line":35,"column":18}},"17":{"start":{"line":39,"column":6},"end":{"line":39,"column":45}},"18":{"start":{"line":40,"column":6},"end":{"line":40,"column":18}},"19":{"start":{"line":45,"column":6},"end":{"line":47,"column":7}},"20":{"start":{"line":46,"column":8},"end":{"line":46,"column":15}},"21":{"start":{"line":49,"column":6},"end":{"line":49,"column":32}},"22":{"start":{"line":50,"column":6},"end":{"line":50,"column":59}},"23":{"start":{"line":52,"column":6},"end":{"line":54,"column":15}},"24":{"start":{"line":53,"column":8},"end":{"line":53,"column":59}},"25":{"start":{"line":59,"column":2},"end":{"line":59,"column":17}}},"branchMap":{"1":{"line":45,"type":"if","locations":[{"start":{"line":45,"column":6},"end":{"line":45,"column":6}},{"start":{"line":45,"column":6},"end":{"line":45,"column":6}}]},"2":{"line":49,"type":"binary-expr","locations":[{"start":{"line":49,"column":16},"end":{"line":49,"column":23}},{"start":{"line":49,"column":27},"end":{"line":49,"column":31}}]},"3":{"line":50,"type":"cond-expr","locations":[{"start":{"line":50,"column":39},"end":{"line":50,"column":43}},{"start":{"line":50,"column":46},"end":{"line":50,"column":58}}]}}},"./src/wreqr.commandStorage.js":{"path":"./src/wreqr.commandStorage.js","s":{"1":1,"2":1,"3":13,"4":13,"5":13,"6":0,"7":1,"8":23,"9":23,"10":8,"11":8,"12":23,"13":3,"14":3,"15":9,"16":9,"17":1},"b":{"1":[0,13],"2":[8,15]},"f":{"1":1,"2":13,"3":23,"4":3,"5":9},"fnMap":{"1":{"name":"(anonymous_1)","line":5,"loc":{"start":{"line":5,"column":24},"end":{"line":5,"column":34}}},"2":{"name":"(anonymous_2)","line":9,"loc":{"start":{"line":9,"column":23},"end":{"line":9,"column":40}}},"3":{"name":"(anonymous_3)","line":24,"loc":{"start":{"line":24,"column":17},"end":{"line":24,"column":38}}},"4":{"name":"(anonymous_4)","line":45,"loc":{"start":{"line":45,"column":16},"end":{"line":45,"column":43}}},"5":{"name":"(anonymous_5)","line":51,"loc":{"start":{"line":51,"column":19},"end":{"line":51,"column":40}}}},"statementMap":{"1":{"start":{"line":5,"column":0},"end":{"line":58,"column":5}},"2":{"start":{"line":9,"column":2},"end":{"line":16,"column":4}},"3":{"start":{"line":10,"column":4},"end":{"line":10,"column":27}},"4":{"start":{"line":11,"column":4},"end":{"line":11,"column":24}},"5":{"start":{"line":13,"column":4},"end":{"line":15,"column":5}},"6":{"start":{"line":14,"column":6},"end":{"line":14,"column":31}},"7":{"start":{"line":19,"column":2},"end":{"line":55,"column":5}},"8":{"start":{"line":25,"column":6},"end":{"line":25,"column":49}},"9":{"start":{"line":28,"column":6},"end":{"line":38,"column":7}},"10":{"start":{"line":31,"column":8},"end":{"line":34,"column":10}},"11":{"start":{"line":37,"column":8},"end":{"line":37,"column":47}},"12":{"start":{"line":40,"column":6},"end":{"line":40,"column":22}},"13":{"start":{"line":46,"column":6},"end":{"line":46,"column":50}},"14":{"start":{"line":47,"column":6},"end":{"line":47,"column":35}},"15":{"start":{"line":52,"column":6},"end":{"line":52,"column":50}},"16":{"start":{"line":53,"column":6},"end":{"line":53,"column":29}},"17":{"start":{"line":57,"column":2},"end":{"line":57,"column":24}}},"branchMap":{"1":{"line":13,"type":"if","locations":[{"start":{"line":13,"column":4},"end":{"line":13,"column":4}},{"start":{"line":13,"column":4},"end":{"line":13,"column":4}}]},"2":{"line":28,"type":"if","locations":[{"start":{"line":28,"column":6},"end":{"line":28,"column":6}},{"start":{"line":28,"column":6},"end":{"line":28,"column":6}}]}}},"./src/wreqr.commands.js":{"path":"./src/wreqr.commands.js","s":{"1":1,"2":1,"3":17,"4":17,"5":17,"6":17,"7":17,"8":6,"9":6,"10":6,"11":3,"12":3,"13":9,"14":9,"15":2,"16":9,"17":17,"18":17,"19":17,"20":15,"21":2,"22":17},"b":{"1":[17,15],"2":[3,3],"3":[17,15],"4":[15,2]},"f":{"1":1,"2":17,"3":6,"4":9,"5":2,"6":17},"fnMap":{"1":{"name":"(anonymous_1)","line":6,"loc":{"start":{"line":6,"column":18},"end":{"line":6,"column":33}}},"2":{"name":"(anonymous_2)","line":13,"loc":{"start":{"line":13,"column":17},"end":{"line":13,"column":34}}},"3":{"name":"(anonymous_3)","line":24,"loc":{"start":{"line":24,"column":13},"end":{"line":24,"column":33}}},"4":{"name":"(anonymous_4)","line":37,"loc":{"start":{"line":37,"column":22},"end":{"line":37,"column":54}}},"5":{"name":"(anonymous_5)","line":41,"loc":{"start":{"line":41,"column":32},"end":{"line":41,"column":46}}},"6":{"name":"(anonymous_6)","line":50,"loc":{"start":{"line":50,"column":24},"end":{"line":50,"column":41}}}},"statementMap":{"1":{"start":{"line":6,"column":0},"end":{"line":64,"column":10}},"2":{"start":{"line":9,"column":2},"end":{"line":62,"column":5}},"3":{"start":{"line":14,"column":6},"end":{"line":14,"column":35}},"4":{"start":{"line":16,"column":6},"end":{"line":16,"column":44}},"5":{"start":{"line":17,"column":6},"end":{"line":17,"column":58}},"6":{"start":{"line":19,"column":6},"end":{"line":19,"column":55}},"7":{"start":{"line":20,"column":6},"end":{"line":20,"column":61}},"8":{"start":{"line":25,"column":6},"end":{"line":25,"column":26}},"9":{"start":{"line":26,"column":6},"end":{"line":26,"column":54}},"10":{"start":{"line":28,"column":6},"end":{"line":32,"column":7}},"11":{"start":{"line":29,"column":8},"end":{"line":29,"column":48}},"12":{"start":{"line":31,"column":8},"end":{"line":31,"column":44}},"13":{"start":{"line":38,"column":6},"end":{"line":38,"column":51}},"14":{"start":{"line":41,"column":6},"end":{"line":43,"column":9}},"15":{"start":{"line":42,"column":8},"end":{"line":42,"column":37}},"16":{"start":{"line":45,"column":6},"end":{"line":45,"column":39}},"17":{"start":{"line":51,"column":6},"end":{"line":51,"column":18}},"18":{"start":{"line":53,"column":6},"end":{"line":53,"column":64}},"19":{"start":{"line":54,"column":6},"end":{"line":58,"column":7}},"20":{"start":{"line":55,"column":8},"end":{"line":55,"column":36}},"21":{"start":{"line":57,"column":8},"end":{"line":57,"column":30}},"22":{"start":{"line":60,"column":6},"end":{"line":60,"column":29}}},"branchMap":{"1":{"line":14,"type":"binary-expr","locations":[{"start":{"line":14,"column":21},"end":{"line":14,"column":28}},{"start":{"line":14,"column":32},"end":{"line":14,"column":34}}]},"2":{"line":28,"type":"if","locations":[{"start":{"line":28,"column":6},"end":{"line":28,"column":6}},{"start":{"line":28,"column":6},"end":{"line":28,"column":6}}]},"3":{"line":53,"type":"binary-expr","locations":[{"start":{"line":53,"column":24},"end":{"line":53,"column":43}},{"start":{"line":53,"column":47},"end":{"line":53,"column":63}}]},"4":{"line":54,"type":"if","locations":[{"start":{"line":54,"column":6},"end":{"line":54,"column":6}},{"start":{"line":54,"column":6},"end":{"line":54,"column":6}}]}}},"./src/wreqr.eventaggregator.js":{"path":"./src/wreqr.eventaggregator.js","s":{"1":1,"2":1,"3":1,"4":1,"5":1},"b":{},"f":{"1":1,"2":9},"fnMap":{"1":{"name":"(anonymous_1)","line":6,"loc":{"start":{"line":6,"column":25},"end":{"line":6,"column":46}}},"2":{"name":"(anonymous_2)","line":8,"loc":{"start":{"line":8,"column":11},"end":{"line":8,"column":21}}}},"statementMap":{"1":{"start":{"line":6,"column":0},"end":{"line":17,"column":16}},"2":{"start":{"line":8,"column":2},"end":{"line":8,"column":24}},"3":{"start":{"line":11,"column":2},"end":{"line":11,"column":36}},"4":{"start":{"line":14,"column":2},"end":{"line":14,"column":42}},"5":{"start":{"line":16,"column":2},"end":{"line":16,"column":12}}},"branchMap":{}},"./src/wreqr.radio.js":{"path":"./src/wreqr.radio.js","s":{"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":42,"10":1,"11":41,"12":73,"13":73,"14":3,"15":3,"16":73,"17":1,"18":3,"19":17,"20":1,"21":1,"22":17,"23":32,"24":32,"25":32,"26":1},"b":{"1":[1,41],"2":[3,70]},"f":{"1":1,"2":1,"3":42,"4":73,"5":1,"6":3,"7":17,"8":17,"9":32},"fnMap":{"1":{"name":"(anonymous_1)","line":5,"loc":{"start":{"line":5,"column":15},"end":{"line":5,"column":30}}},"2":{"name":"(anonymous_2)","line":8,"loc":{"start":{"line":8,"column":14},"end":{"line":8,"column":25}}},"3":{"name":"(anonymous_3)","line":18,"loc":{"start":{"line":18,"column":13},"end":{"line":18,"column":35}}},"4":{"name":"(anonymous_4)","line":26,"loc":{"start":{"line":26,"column":17},"end":{"line":26,"column":39}}},"5":{"name":"(anonymous_5)","line":37,"loc":{"start":{"line":37,"column":19},"end":{"line":37,"column":30}}},"6":{"name":"(anonymous_6)","line":38,"loc":{"start":{"line":38,"column":45},"end":{"line":38,"column":62}}},"7":{"name":"(anonymous_7)","line":39,"loc":{"start":{"line":39,"column":40},"end":{"line":39,"column":57}}},"8":{"name":"(anonymous_8)","line":75,"loc":{"start":{"line":75,"column":20},"end":{"line":75,"column":52}}},"9":{"name":"(anonymous_9)","line":76,"loc":{"start":{"line":76,"column":11},"end":{"line":76,"column":33}}}},"statementMap":{"1":{"start":{"line":5,"column":0},"end":{"line":86,"column":10}},"2":{"start":{"line":8,"column":2},"end":{"line":14,"column":4}},"3":{"start":{"line":9,"column":4},"end":{"line":9,"column":24}},"4":{"start":{"line":10,"column":4},"end":{"line":10,"column":19}},"5":{"start":{"line":11,"column":4},"end":{"line":11,"column":23}},"6":{"start":{"line":12,"column":4},"end":{"line":12,"column":21}},"7":{"start":{"line":13,"column":4},"end":{"line":13,"column":25}},"8":{"start":{"line":16,"column":2},"end":{"line":44,"column":5}},"9":{"start":{"line":19,"column":6},"end":{"line":21,"column":7}},"10":{"start":{"line":20,"column":8},"end":{"line":20,"column":55}},"11":{"start":{"line":23,"column":6},"end":{"line":23,"column":45}},"12":{"start":{"line":27,"column":6},"end":{"line":27,"column":48}},"13":{"start":{"line":29,"column":6},"end":{"line":32,"column":7}},"14":{"start":{"line":30,"column":8},"end":{"line":30,"column":49}},"15":{"start":{"line":31,"column":8},"end":{"line":31,"column":46}},"16":{"start":{"line":34,"column":6},"end":{"line":34,"column":21}},"17":{"start":{"line":38,"column":6},"end":{"line":42,"column":15}},"18":{"start":{"line":39,"column":8},"end":{"line":41,"column":17}},"19":{"start":{"line":40,"column":10},"end":{"line":40,"column":67}},"20":{"start":{"line":47,"column":2},"end":{"line":73,"column":4}},"21":{"start":{"line":75,"column":2},"end":{"line":82,"column":4}},"22":{"start":{"line":76,"column":4},"end":{"line":81,"column":6}},"23":{"start":{"line":77,"column":6},"end":{"line":77,"column":65}},"24":{"start":{"line":78,"column":6},"end":{"line":78,"column":58}},"25":{"start":{"line":80,"column":6},"end":{"line":80,"column":55}},"26":{"start":{"line":84,"column":2},"end":{"line":84,"column":21}}},"branchMap":{"1":{"line":19,"type":"if","locations":[{"start":{"line":19,"column":6},"end":{"line":19,"column":6}},{"start":{"line":19,"column":6},"end":{"line":19,"column":6}}]},"2":{"line":29,"type":"if","locations":[{"start":{"line":29,"column":6},"end":{"line":29,"column":6}},{"start":{"line":29,"column":6},"end":{"line":29,"column":6}}]}}},"./src/wreqr.requestresponse.js":{"path":"./src/wreqr.requestresponse.js","s":{"1":1,"2":1,"3":3,"4":3,"5":3,"6":3},"b":{"1":[3,0]},"f":{"1":1,"2":3},"fnMap":{"1":{"name":"(anonymous_1)","line":6,"loc":{"start":{"line":6,"column":25},"end":{"line":6,"column":40}}},"2":{"name":"(anonymous_2)","line":10,"loc":{"start":{"line":10,"column":13},"end":{"line":10,"column":23}}}},"statementMap":{"1":{"start":{"line":6,"column":0},"end":{"line":19,"column":10}},"2":{"start":{"line":9,"column":2},"end":{"line":17,"column":5}},"3":{"start":{"line":11,"column":6},"end":{"line":11,"column":30}},"4":{"start":{"line":12,"column":6},"end":{"line":12,"column":58}},"5":{"start":{"line":13,"column":6},"end":{"line":15,"column":7}},"6":{"start":{"line":14,"column":8},"end":{"line":14,"column":55}}},"branchMap":{"1":{"line":13,"type":"if","locations":[{"start":{"line":13,"column":6},"end":{"line":13,"column":6}},{"start":{"line":13,"column":6},"end":{"line":13,"column":6}}]}}}} \ No newline at end of file diff --git a/reports/coverage/index.html b/reports/coverage/index.html index 89d0867..d9f7fb2 100644 --- a/reports/coverage/index.html +++ b/reports/coverage/index.html @@ -183,16 +183,16 @@

Code coverage report for All files

- Statements: 97.56% (80 / 82)      + Statements: 97.74% (130 / 133)      - Branches: 86.36% (19 / 22)      + Branches: 87.5% (28 / 32)      - Functions: 100% (27 / 27)      + Functions: 100% (44 / 44)      - Lines: 97.56% (80 / 82)      + Lines: 97.74% (130 / 133)     

@@ -229,15 +229,15 @@

src/ - - 97.5% - (78 / 80) - 86.36% - (19 / 22) + + 97.71% + (128 / 131) + 87.5% + (28 / 32) 100% - (26 / 26) - 97.5% - (78 / 80) + (43 / 43) + 97.71% + (128 / 131) @@ -245,7 +245,7 @@

diff --git a/reports/coverage/spec/javascripts/support/index.html b/reports/coverage/spec/javascripts/support/index.html index 5884220..a3e218e 100644 --- a/reports/coverage/spec/javascripts/support/index.html +++ b/reports/coverage/spec/javascripts/support/index.html @@ -232,7 +232,7 @@

diff --git a/reports/coverage/spec/javascripts/support/wreqrHelper.js.html b/reports/coverage/spec/javascripts/support/wreqrHelper.js.html index 2aa1fbb..44c2d7c 100644 --- a/reports/coverage/spec/javascripts/support/wreqrHelper.js.html +++ b/reports/coverage/spec/javascripts/support/wreqrHelper.js.html @@ -213,7 +213,7 @@

diff --git a/reports/coverage/src/index.html b/reports/coverage/src/index.html index d3d486f..a098a89 100644 --- a/reports/coverage/src/index.html +++ b/reports/coverage/src/index.html @@ -183,16 +183,16 @@

Code coverage report for src/

- Statements: 97.5% (78 / 80)      + Statements: 97.71% (128 / 131)      - Branches: 86.36% (19 / 22)      + Branches: 87.5% (28 / 32)      - Functions: 100% (26 / 26)      + Functions: 100% (43 / 43)      - Lines: 97.5% (78 / 80)      + Lines: 97.71% (128 / 131)     

All files » src/
@@ -215,6 +215,19 @@

+ wreqr.channel.js + + 96% + (24 / 25) + 83.33% + (5 / 6) + 100% + (8 / 8) + 96% + (24 / 25) + + + wreqr.commandStorage.js 94.12% @@ -279,6 +292,19 @@

(3 / 3) + + wreqr.radio.js + + 100% + (26 / 26) + 100% + (4 / 4) + 100% + (9 / 9) + 100% + (26 / 26) + + wreqr.requestresponse.js @@ -297,7 +323,7 @@

diff --git a/reports/coverage/src/wreqr.channel.js.html b/reports/coverage/src/wreqr.channel.js.html new file mode 100644 index 0000000..fed6661 --- /dev/null +++ b/reports/coverage/src/wreqr.channel.js.html @@ -0,0 +1,485 @@ + + + + Code coverage report for src/wreqr.channel.js + + + + + + + +
+

Code coverage report for src/wreqr.channel.js

+

+ + Statements: 96% (24 / 25)      + + + Branches: 83.33% (5 / 6)      + + + Functions: 100% (8 / 8)      + + + Lines: 96% (24 / 25)      + +

+
All files » src/ » wreqr.channel.js
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61  +  +  +  +  +1 +  +  +1 +7 +7 +7 +7 +  +  +1 +  +  +  +8 +8 +8 +8 +8 +  +  +  +  +2 +2 +  +  +  +2 +2 +  +  +  +2 +2 +  +  +  +  +6 +  +  +  +6 +6 +  +6 +12 +  +  +  +  +  +1 +  + 
// Wreqr.Channel
+// --------------
+//
+// An object that wraps the three messaging systems:
+// EventAggregator, RequestResponse, Commands
+Wreqr.Channel = (function(Wreqr){
+  "use strict";
+ 
+  var Channel = function(channelName) {
+    this.vent        = new Backbone.Wreqr.EventAggregator();
+    this.reqres      = new Backbone.Wreqr.RequestResponse();
+    this.commands    = new Backbone.Wreqr.Commands();
+    this.channelName = channelName;
+  };
+ 
+  _.extend(Channel.prototype, {
+ 
+    // Remove all handlers from the messaging systems of this channel
+    reset: function() {
+      this.vent.off();
+      this.vent.stopListening();
+      this.reqres.removeAllHandlers();
+      this.commands.removeAllHandlers();
+      return this;
+    },
+ 
+    // Connect a hash of events; one for each messaging system
+    connectEvents: function(hash, context) {
+      this._connect('vent', hash, context);
+      return this;
+    },
+ 
+    connectCommands: function(hash, context) {
+      this._connect('commands', hash, context);
+      return this;
+    },
+ 
+    connectRequests: function(hash, context) {
+      this._connect('reqres', hash, context);
+      return this;
+    },
+ 
+    // Attach the handlers to a given message system `type`
+    _connect: function(type, hash, context) {
+      Iif (!hash) {
+        return;
+      }
+ 
+      context = context || this;
+      var method = (type === 'vent') ? 'on' : 'setHandler';
+ 
+      _.each(hash, function(fn, eventName) {
+        this[type][method](eventName, _.bind(fn, context));
+      }, this);
+    }
+  });
+ 
+ 
+  return Channel;
+})(Wreqr);
+ 
+ +
+ + + + + + + + diff --git a/reports/coverage/src/wreqr.commandStorage.js.html b/reports/coverage/src/wreqr.commandStorage.js.html index 2dc1d7f..418020d 100644 --- a/reports/coverage/src/wreqr.commandStorage.js.html +++ b/reports/coverage/src/wreqr.commandStorage.js.html @@ -266,10 +266,10 @@

    1 -6 -6 +13 +13   -6 +13       @@ -281,22 +281,22 @@

      -15 +23     -15 +23     -6 +8           -6 +8     -15 +23       @@ -308,8 +308,8 @@

      -5 -5 +9 +9       @@ -378,7 +378,7 @@

diff --git a/reports/coverage/src/wreqr.commands.js.html b/reports/coverage/src/wreqr.commands.js.html index 1173378..9fb0313 100644 --- a/reports/coverage/src/wreqr.commands.js.html +++ b/reports/coverage/src/wreqr.commands.js.html @@ -276,13 +276,13 @@

      -10 +17   -10 -10 +17 +17   -10 -10 +17 +17       @@ -300,29 +300,29 @@

      -5 +9     -5 +9 2     -5 +9           -10 +17   -10 -10 -8 +17 +17 +15   2     -10 +17       @@ -396,7 +396,7 @@

diff --git a/reports/coverage/src/wreqr.eventaggregator.js.html b/reports/coverage/src/wreqr.eventaggregator.js.html index feef5e8..e00aa9f 100644 --- a/reports/coverage/src/wreqr.eventaggregator.js.html +++ b/reports/coverage/src/wreqr.eventaggregator.js.html @@ -255,7 +255,7 @@

diff --git a/reports/coverage/src/wreqr.handlers.js.html b/reports/coverage/src/wreqr.handlers.js.html index f4ca81d..91b60de 100644 --- a/reports/coverage/src/wreqr.handlers.js.html +++ b/reports/coverage/src/wreqr.handlers.js.html @@ -297,10 +297,10 @@

    1 -22 -22 +36 +36   -22 +36       @@ -329,14 +329,14 @@

      -19 +27         -19 +27   -19 +27       @@ -367,7 +367,7 @@

      -1 +17       @@ -465,7 +465,7 @@

diff --git a/reports/coverage/src/wreqr.js.html b/reports/coverage/src/wreqr.js.html index bc57a8b..7b3e02c 100644 --- a/reports/coverage/src/wreqr.js.html +++ b/reports/coverage/src/wreqr.js.html @@ -211,7 +211,9 @@

10 11 12 -131 +13 +14 +151   1   @@ -221,6 +223,8 @@

      +  +  1    
Backbone.Wreqr = (function(Backbone, Marionette, _){
@@ -232,6 +236,8 @@ 

// @include wreqr.commands.js // @include wreqr.requestresponse.js // @include wreqr.eventaggregator.js + // @include wreqr.channel.js + // @include wreqr.radio.js   return Wreqr; })(Backbone, Backbone.Marionette, _); @@ -240,7 +246,7 @@

diff --git a/reports/coverage/src/wreqr.radio.js.html b/reports/coverage/src/wreqr.radio.js.html new file mode 100644 index 0000000..b2b5616 --- /dev/null +++ b/reports/coverage/src/wreqr.radio.js.html @@ -0,0 +1,563 @@ + + + + Code coverage report for src/wreqr.radio.js + + + + + + + +
+

Code coverage report for src/wreqr.radio.js

+

+ + Statements: 100% (26 / 26)      + + + Branches: 100% (4 / 4)      + + + Functions: 100% (9 / 9)      + + + Lines: 100% (26 / 26)      + +

+
All files » src/ » wreqr.radio.js
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87  +  +  +  +1 +  +  +1 +1 +1 +1 +1 +1 +  +  +1 +  +  +42 +1 +  +  +41 +  +  +  +73 +  +73 +3 +3 +  +  +73 +  +  +  +1 +3 +17 +  +  +  +  +  +  +1 +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1 +17 +32 +32 +  +32 +  +  +  +1 +  +  + 
// Wreqr.Radio
+// --------------
+//
+// An object that lets you communicate with many channels.
+Wreqr.radio = (function(Wreqr){
+  "use strict";
+ 
+  var Radio = function() {
+    this._channels = {};
+    this.vent = {};
+    this.commands = {};
+    this.reqres = {};
+    this._proxyMethods();
+  };
+ 
+  _.extend(Radio.prototype, {
+ 
+    channel: function(channelName) {
+      if (!channelName) {
+        throw new Error('Channel must receive a name');
+      }
+ 
+      return this._getChannel( channelName );
+    },
+ 
+    _getChannel: function(channelName) {
+      var channel = this._channels[channelName];
+ 
+      if(!channel) {
+        channel = new Wreqr.Channel(channelName);
+        this._channels[channelName] = channel;
+      }
+ 
+      return channel;
+    },
+ 
+    _proxyMethods: function() {
+      _.each(['vent', 'commands', 'reqres'], function(system) {
+        _.each( messageSystems[system], function(method) {
+          this[system][method] = proxyMethod(this, system, method);
+        }, this);
+      }, this);
+    }
+  });
+ 
+ 
+  var messageSystems = {
+    vent: [
+      'on',
+      'off',
+      'trigger',
+      'once',
+      'stopListening',
+      'listenTo',
+      'listenToOnce'
+    ],
+ 
+    commands: [
+      'execute',
+      'setHandler',
+      'setHandlers',
+      'removeHandler',
+      'removeAllHandlers'
+    ],
+ 
+    reqres: [
+      'request',
+      'setHandler',
+      'setHandlers',
+      'removeHandler',
+      'removeAllHandlers'
+    ]
+  };
+ 
+  var proxyMethod = function(radio, system, method) {
+    return function(channelName) {
+      var messageSystem = radio._getChannel(channelName)[system];
+      var args = Array.prototype.slice.call(arguments, 1);
+ 
+      messageSystem[method].apply(messageSystem, args);
+    };
+  };
+ 
+  return new Radio();
+ 
+})(Wreqr);
+ 
+ +
+ + + + + + + + diff --git a/reports/coverage/src/wreqr.requestresponse.js.html b/reports/coverage/src/wreqr.requestresponse.js.html index 1aaf42a..b810534 100644 --- a/reports/coverage/src/wreqr.requestresponse.js.html +++ b/reports/coverage/src/wreqr.requestresponse.js.html @@ -261,7 +261,7 @@