backbone.radio
Advanced tools
Comparing version 0.4.1 to 0.5.0
{ | ||
"name": "backbone.radio", | ||
"version": "0.4.1", | ||
"version": "0.5.0", | ||
"homepage": "https://github.com/jmeas/backbone.radio", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -1,2 +0,2 @@ | ||
// Backbone.Radio v0.4.0 | ||
// Backbone.Radio v0.4.1 | ||
(function(root, factory) { | ||
@@ -19,8 +19,10 @@ if (typeof define === 'function' && define.amd) { | ||
var slice = Array.prototype.slice; | ||
var previousRadio = Backbone.Radio; | ||
var Radio = Backbone.Radio = {}; | ||
Radio.VERSION = '0.4.0'; | ||
Radio.VERSION = '0.4.1'; | ||
Radio.noConflict = function () { | ||
@@ -30,5 +32,3 @@ Backbone.Radio = previousRadio; | ||
}; | ||
var slice = Array.prototype.slice; | ||
/* | ||
@@ -138,3 +138,3 @@ * Backbone.Radio | ||
react: function(name, callback, context) { | ||
comply: function(name, callback, context) { | ||
this._commands || (this._commands = {}); | ||
@@ -150,12 +150,12 @@ | ||
reactOnce: function(name, callback, context) { | ||
complyOnce: function(name, callback, context) { | ||
var self = this; | ||
var once = _.once(function() { | ||
self.stopReacting(name); | ||
self.stopComplying(name); | ||
return callback.apply(this, arguments); | ||
}); | ||
return this.react(name, once, context); | ||
return this.comply(name, once, context); | ||
}, | ||
stopReacting: function(name) { | ||
stopComplying: function(name) { | ||
var store = this._commands; | ||
@@ -266,3 +266,3 @@ if (!name) { | ||
this.stopListening(); | ||
this.stopReacting(); | ||
this.stopComplying(); | ||
this.stopReplying(); | ||
@@ -277,3 +277,3 @@ return this; | ||
connectCommands: function(hash, context) { | ||
return this._connect('react', hash, context); | ||
return this._connect('comply', hash, context); | ||
}, | ||
@@ -280,0 +280,0 @@ |
@@ -1,4 +0,4 @@ | ||
// Backbone.Radio v0.4.0 | ||
// Backbone.Radio v0.4.1 | ||
!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){return h[a]||(h[a]=b.partial(f.log,a))}function d(a){return b.isFunction(a)?a:b.constant(a)}var e=a.Radio,f=a.Radio={};f.VERSION="0.4.0",f.noConflict=function(){return a.Radio=e,this};var g=Array.prototype.slice;b.extend(f,{_channels:{},DEBUG:!1,channel:function(a){if(!a)throw new Error("You must provide a name for the channel.");return f._getChannel(a)},_getChannel:function(a){var b=f._channels[a];return b||(b=new f.Channel(a),f._channels[a]=b),b}});var h={};b.extend(f,{log:function(a,b){var c=g.call(arguments,2);console.log("["+a+'] "'+b+'"',c)},tuneIn:function(a){var b=f.channel(a);return b._tunedIn=!0,b.on("all",c(a)),this},tuneOut:function(a){var b=f.channel(a);return b._tunedIn=!1,b.off("all",c(a)),delete h[a],this}}),f.Commands={command:function(a){var b=g.call(arguments,1),c=this._channelName;if(c&&this._tunedIn&&f.log.apply(this,[c,a].concat(b)),this._commands&&this._commands[a]){var d=this._commands[a];d.callback.apply(d.context,b)}else if(f.DEBUG){var e=c?" on the "+c+" channel":"";console.warn("An unhandled event was fired"+e+': "'+a+'"')}return this},react:function(a,b,c){return this._commands||(this._commands={}),this._commands[a]={callback:b,context:c||this},this},reactOnce:function(a,c,d){var e=this,f=b.once(function(){return e.stopReacting(a),c.apply(this,arguments)});return this.react(a,f,d)},stopReacting:function(a){var b=this._commands;if(a){if(b&&b[a])delete b[a];else if(f.DEBUG){var c=this._channelName,d=c?" on the "+c+" channel.":"";console.warn('Attempted to remove the unregistered command "'+a+'"'+d)}}else delete this._commands;return this}},f.Requests={request:function(a){var b=g.call(arguments,1),c=this._channelName;if(c&&this._tunedIn&&f.log.apply(this,[c,a].concat(b)),this._requests&&this._requests[a]){var d=this._requests[a];return d.callback.apply(d.context,b)}if(f.DEBUG){var e=c?" on the "+c+" channel":"";console.warn("An unhandled event was fired"+e+': "'+a+'"')}},reply:function(a,b,c){return this._requests||(this._requests={}),this._requests[a]={callback:d(b),context:c||this},this},replyOnce:function(a,c,e){var f=this,g=b.once(function(){return f.stopReplying(a),d(c).apply(this,arguments)});return this.reply(a,g,e)},stopReplying:function(a){var b=this._requests;if(a){if(b&&b[a])delete b[a];else if(f.DEBUG){var c=this._channelName,d=c?" on the "+c+" channel.":"";console.warn('Attempted to remove the unregistered request "'+a+'"'+d)}}else delete this._requests;return this}},f.Channel=function(c){this._channelName=c,b.extend(this,a.Events,f.Commands,f.Requests)},b.extend(f.Channel.prototype,{reset:function(){return this.off(),this.stopListening(),this.stopReacting(),this.stopReplying(),this},connectEvents:function(a,b){return this._connect("on",a,b)},connectCommands:function(a,b){return this._connect("react",a,b)},connectRequests:function(a,b){return this._connect("reply",a,b)},_connect:function(a,c,d){return c?(b.each(c,function(b,c){this[a](c,b,d||this)},this),this):void 0}});var i,j,k=[a.Events,f.Commands,f.Requests];return b.each(k,function(a){b.each(a,function(a,b){f[b]=function(a){return j=g.call(arguments,2),i=this.channel(a),i[b].apply(i,j)}})}),f}); | ||
!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){return h[a]||(h[a]=b.partial(g.log,a))}function d(a){return b.isFunction(a)?a:b.constant(a)}var e=Array.prototype.slice,f=a.Radio,g=a.Radio={};g.VERSION="0.4.1",g.noConflict=function(){return a.Radio=f,this},b.extend(g,{_channels:{},DEBUG:!1,channel:function(a){if(!a)throw new Error("You must provide a name for the channel.");return g._getChannel(a)},_getChannel:function(a){var b=g._channels[a];return b||(b=new g.Channel(a),g._channels[a]=b),b}});var h={};b.extend(g,{log:function(a,b){var c=e.call(arguments,2);console.log("["+a+'] "'+b+'"',c)},tuneIn:function(a){var b=g.channel(a);return b._tunedIn=!0,b.on("all",c(a)),this},tuneOut:function(a){var b=g.channel(a);return b._tunedIn=!1,b.off("all",c(a)),delete h[a],this}}),g.Commands={command:function(a){var b=e.call(arguments,1),c=this._channelName;if(c&&this._tunedIn&&g.log.apply(this,[c,a].concat(b)),this._commands&&this._commands[a]){var d=this._commands[a];d.callback.apply(d.context,b)}else if(g.DEBUG){var f=c?" on the "+c+" channel":"";console.warn("An unhandled event was fired"+f+': "'+a+'"')}return this},comply:function(a,b,c){return this._commands||(this._commands={}),this._commands[a]={callback:b,context:c||this},this},complyOnce:function(a,c,d){var e=this,f=b.once(function(){return e.stopComplying(a),c.apply(this,arguments)});return this.comply(a,f,d)},stopComplying:function(a){var b=this._commands;if(a){if(b&&b[a])delete b[a];else if(g.DEBUG){var c=this._channelName,d=c?" on the "+c+" channel.":"";console.warn('Attempted to remove the unregistered command "'+a+'"'+d)}}else delete this._commands;return this}},g.Requests={request:function(a){var b=e.call(arguments,1),c=this._channelName;if(c&&this._tunedIn&&g.log.apply(this,[c,a].concat(b)),this._requests&&this._requests[a]){var d=this._requests[a];return d.callback.apply(d.context,b)}if(g.DEBUG){var f=c?" on the "+c+" channel":"";console.warn("An unhandled event was fired"+f+': "'+a+'"')}},reply:function(a,b,c){return this._requests||(this._requests={}),this._requests[a]={callback:d(b),context:c||this},this},replyOnce:function(a,c,e){var f=this,g=b.once(function(){return f.stopReplying(a),d(c).apply(this,arguments)});return this.reply(a,g,e)},stopReplying:function(a){var b=this._requests;if(a){if(b&&b[a])delete b[a];else if(g.DEBUG){var c=this._channelName,d=c?" on the "+c+" channel.":"";console.warn('Attempted to remove the unregistered request "'+a+'"'+d)}}else delete this._requests;return this}},g.Channel=function(c){this._channelName=c,b.extend(this,a.Events,g.Commands,g.Requests)},b.extend(g.Channel.prototype,{reset:function(){return this.off(),this.stopListening(),this.stopComplying(),this.stopReplying(),this},connectEvents:function(a,b){return this._connect("on",a,b)},connectCommands:function(a,b){return this._connect("comply",a,b)},connectRequests:function(a,b){return this._connect("reply",a,b)},_connect:function(a,c,d){return c?(b.each(c,function(b,c){this[a](c,b,d||this)},this),this):void 0}});var i,j,k=[a.Events,g.Commands,g.Requests];return b.each(k,function(a){b.each(a,function(a,b){g[b]=function(a){return j=e.call(arguments,2),i=this.channel(a),i[b].apply(i,j)}})}),g}); | ||
//# sourceMappingURL=backbone.radio.min.map |
@@ -91,3 +91,3 @@ module.exports = function(grunt) { | ||
coverage: { | ||
APP_DIR_FOR_CODE_COVERAGE: '../../coverage/build/' | ||
APP_DIR_FOR_CODE_COVERAGE: '../../coverage/src/' | ||
} | ||
@@ -97,3 +97,3 @@ }, | ||
instrument: { | ||
files: 'build/backbone.radio.js', | ||
files: 'src/*.js', | ||
options: { | ||
@@ -133,3 +133,3 @@ lazy: true, | ||
grunt.registerTask('coverage', 'Generate coverage report for the library', ['build', 'env:coverage', 'instrument', 'mochaTest', 'storeCoverage', 'makeReport', 'coveralls']); | ||
grunt.registerTask('coverage', 'Generate coverage report for the library', ['env:coverage', 'instrument', 'mochaTest', 'storeCoverage', 'makeReport', 'coveralls']); | ||
@@ -136,0 +136,0 @@ grunt.registerTask('build', 'Build the library', ['test', 'preprocess:radio', 'template', 'concat', 'uglify']); |
{ | ||
"name": "backbone.radio", | ||
"description": "The semantic messaging system for Backbone applications.", | ||
"version": "0.4.1", | ||
"version": "0.5.0", | ||
"homepage": "https://github.com/jmeas/backbone.radio", | ||
@@ -6,0 +6,0 @@ "main": "build/backbone.radio.js", |
@@ -15,6 +15,7 @@ # Backbone.Radio | ||
Clone this repository or install via [Bower](http://bower.io/). | ||
Clone this repository or install via [Bower](http://bower.io/) or [npm](https://www.npmjs.org/). | ||
```js | ||
``` | ||
bower install backbone.radio | ||
npm install backbone.radio | ||
``` | ||
@@ -33,4 +34,13 @@ | ||
this.listenTo(someModel, 'change', myCallback); | ||
// Later on, the model triggers a change event when it has been changed | ||
someModel.trigger('change'); | ||
``` | ||
Let's look at a diagram for Backbone.Events: | ||
<p align='center'> | ||
<img src='https://i.cloudup.com/M3inUilhIf-3000x3000.png' alt='Backbone.Events diagram'> | ||
</p> | ||
It goes without saying that Backbone.Events is incredibly useful when you mix it into instances of Classes. But what | ||
@@ -76,4 +86,4 @@ if you had a standalone Object with an instance of Backbone.Events on it? If you were to do this, you will find yourself | ||
```js | ||
// Set up a view to react to a command | ||
myView.react('render', myView.render); | ||
// Set up a view to comply with a command | ||
myView.comply('render', myView.render); | ||
@@ -88,4 +98,10 @@ // Causes the view to render | ||
Anyway, the example I showed above is a bit contrived. You might ask yourself, 'Now why in the world would I fire the command when I can | ||
just call the method directly?' The answer is that you wouldn't. I only meant for that example to be used as a means to familiarize yourself | ||
The following diagram illustrates the Commands pattern: | ||
<p align='center'> | ||
<img src='https://i.cloudup.com/XWGBQlkwTn-3000x3000.png' alt='Backbone.Commands diagram'> | ||
</p> | ||
You might ask yourself, 'Now why in the world would I fire the command when I can | ||
just call the method directly?' The answer is that you wouldn't. I only meant for the above example to be used as a means to familiarize yourself | ||
with the way Commands works. The real utility of Commands comes when it is used in an independent message bus. But more on that later – let's | ||
@@ -119,2 +135,8 @@ first look at Requests. | ||
Here's a diagram of the Requests pattern: | ||
<p align='center'> | ||
<img src='https://i.cloudup.com/2NtOFRO9DH-3000x3000.png' alt='Backbone.Requests diagram'> | ||
</p> | ||
### Channels | ||
@@ -139,3 +161,3 @@ | ||
globalChannel.react('some:action', function() { | ||
globalChannel.comply('some:action', function() { | ||
console.log('I was told to execute some action'); | ||
@@ -156,3 +178,3 @@ }); | ||
globalCh.request('some:request'); | ||
globalChannel.request('some:request'); | ||
``` | ||
@@ -182,3 +204,3 @@ | ||
##### `react( commandName, callback [, context] )` | ||
##### `comply( commandName, callback [, context] )` | ||
@@ -190,3 +212,3 @@ Register a handler for `commandName` on this object. `callback` will be executed whenever the command is run. Optionally | ||
##### `reactOnce( commandName, callback [, context] )` | ||
##### `complyOnce( commandName, callback [, context] )` | ||
@@ -197,5 +219,5 @@ Register a handler for `commandName` that only executes a single time. | ||
##### `stopReacting( [commandName] )` | ||
##### `stopComplying( [commandName] )` | ||
If `commandName` is passed then that reaction is removed from the object. Otherwise, all reactions are removed. | ||
If `commandName` is passed then that handler is removed from the object. Otherwise, all handlers are removed. | ||
@@ -254,3 +276,3 @@ Returns the instance of Commands. | ||
A convenience method for connecting a hash of Commands reactions to the channel. Returns the channel. | ||
A convenience method for connecting a hash of Commands handles to the channel. Returns the channel. | ||
@@ -257,0 +279,0 @@ ##### `connectRequests( requestsHash )` |
@@ -20,3 +20,3 @@ /* | ||
this.stopListening(); | ||
this.stopReacting(); | ||
this.stopComplying(); | ||
this.stopReplying(); | ||
@@ -31,3 +31,3 @@ return this; | ||
connectCommands: function(hash, context) { | ||
return this._connect('react', hash, context); | ||
return this._connect('comply', hash, context); | ||
}, | ||
@@ -34,0 +34,0 @@ |
@@ -33,3 +33,3 @@ /* | ||
react: function(name, callback, context) { | ||
comply: function(name, callback, context) { | ||
this._commands || (this._commands = {}); | ||
@@ -45,12 +45,12 @@ | ||
reactOnce: function(name, callback, context) { | ||
complyOnce: function(name, callback, context) { | ||
var self = this; | ||
var once = _.once(function() { | ||
self.stopReacting(name); | ||
self.stopComplying(name); | ||
return callback.apply(this, arguments); | ||
}); | ||
return this.react(name, once, context); | ||
return this.comply(name, once, context); | ||
}, | ||
stopReacting: function(name) { | ||
stopComplying: function(name) { | ||
var store = this._commands; | ||
@@ -57,0 +57,0 @@ if (!name) { |
@@ -18,15 +18,5 @@ (function(root, factory) { | ||
var previousRadio = Backbone.Radio; | ||
var Radio = Backbone.Radio = {}; | ||
Radio.VERSION = '<%= version %>'; | ||
Radio.noConflict = function () { | ||
Backbone.Radio = previousRadio; | ||
return this; | ||
}; | ||
var slice = Array.prototype.slice; | ||
// @include misc.js | ||
// @include radio.js | ||
@@ -33,0 +23,0 @@ // @include tune-in.js |
@@ -8,3 +8,2 @@ var requireHelper = require('./require_helper'); | ||
global.Backbone = require('backbone'); | ||
global.Radio = requireHelper('backbone.radio'); | ||
@@ -15,1 +14,13 @@ chai.use(sinonChai); | ||
global.sinon = sinon; | ||
global.slice = Array.prototype.slice; | ||
requireHelper('misc'); | ||
global.Radio = Backbone.Radio; | ||
requireHelper('radio'); | ||
requireHelper('tune-in'); | ||
requireHelper('commands'); | ||
requireHelper('requests'); | ||
requireHelper('channel'); | ||
requireHelper('proxy'); |
module.exports = function (path) { | ||
return require((process.env.APP_DIR_FOR_CODE_COVERAGE || '../../.tmp/') + path); | ||
return require((process.env.APP_DIR_FOR_CODE_COVERAGE || '../../src/') + path); | ||
}; |
@@ -49,3 +49,3 @@ describe('Channel:', function () { | ||
this.stopListeningStub = this.sinon.stub(this.channel, 'stopListening'); | ||
this.stopReactingStub = this.sinon.stub(this.channel, 'stopReacting'); | ||
this.stopComplyingStub = this.sinon.stub(this.channel, 'stopComplying'); | ||
this.stopReplyingStub = this.sinon.stub(this.channel, 'stopReplying'); | ||
@@ -63,3 +63,3 @@ this.resetSpy = this.sinon.spy(this.channel, 'reset'); | ||
it('should call the reset functions of Backbone.Radio.Commands', function() { | ||
expect(this.stopReactingStub).to.have.been.calledOnce; | ||
expect(this.stopComplyingStub).to.have.been.calledOnce; | ||
}); | ||
@@ -66,0 +66,0 @@ |
@@ -5,5 +5,5 @@ describe('Commands:', function() { | ||
this.commandSpy = this.sinon.spy(this.Commands, 'command'); | ||
this.reactSpy = this.sinon.spy(this.Commands, 'react'); | ||
this.reactOnceSpy = this.sinon.spy(this.Commands, 'reactOnce'); | ||
this.stopReactingSpy = this.sinon.spy(this.Commands, 'stopReacting'); | ||
this.complySpy = this.sinon.spy(this.Commands, 'comply'); | ||
this.complyOnceSpy = this.sinon.spy(this.Commands, 'complyOnce'); | ||
this.stopComplyingSpy = this.sinon.spy(this.Commands, 'stopComplying'); | ||
}); | ||
@@ -34,3 +34,3 @@ | ||
beforeEach(function() { | ||
this.Commands.react(this.actionName, this.callbackStub); | ||
this.Commands.comply(this.actionName, this.callbackStub); | ||
this.Commands.command(this.actionName, this.argumentOne, this.argumentTwo); | ||
@@ -49,4 +49,4 @@ }); | ||
it('should always return the instance of Commands from `react`', function() { | ||
expect(this.reactSpy) | ||
it('should always return the instance of Commands from `comply`', function() { | ||
expect(this.complySpy) | ||
.to.have.been.calledOnce | ||
@@ -64,3 +64,3 @@ .and.to.have.always.returned(this.Commands); | ||
this.context = {}; | ||
this.Commands.react(this.actionName, this.callbackStub, this.context); | ||
this.Commands.comply(this.actionName, this.callbackStub, this.context); | ||
this.Commands.command(this.actionName, this.argumentOne, this.argumentTwo); | ||
@@ -79,4 +79,4 @@ }); | ||
it('should always return the instance of Commands from `react`', function() { | ||
expect(this.reactSpy) | ||
it('should always return the instance of Commands from `comply`', function() { | ||
expect(this.complySpy) | ||
.to.have.been.calledOnce | ||
@@ -100,3 +100,3 @@ .and.to.have.always.returned(this.Commands); | ||
this.Commands.react(this.actionName, this.callbackStub); | ||
this.Commands.comply(this.actionName, this.callbackStub); | ||
this.Commands.command(this.actionName); | ||
@@ -113,4 +113,4 @@ this.Commands.command(this.actionName); | ||
it('should always return the instance of Commands from `react`', function() { | ||
expect(this.reactSpy) | ||
it('should always return the instance of Commands from `comply`', function() { | ||
expect(this.complySpy) | ||
.to.have.been.calledOnce | ||
@@ -129,3 +129,3 @@ .and.to.have.always.returned(this.Commands); | ||
this.Commands.reactOnce(this.actionName, this.callbackStub); | ||
this.Commands.complyOnce(this.actionName, this.callbackStub); | ||
this.Commands.command(this.actionName, this.argumentOne, this.argumentTwo); | ||
@@ -148,4 +148,4 @@ this.Commands.command(this.actionName, this.argumentOne); | ||
it('should always return the instance of Commands from `reactOnce`', function() { | ||
expect(this.reactOnceSpy) | ||
it('should always return the instance of Commands from `complyOnce`', function() { | ||
expect(this.complyOnceSpy) | ||
.to.have.been.calledOnce | ||
@@ -165,3 +165,3 @@ .and.to.have.always.returned(this.Commands); | ||
this.Commands.reactOnce(this.actionName, this.callbackStub, this.context); | ||
this.Commands.complyOnce(this.actionName, this.callbackStub, this.context); | ||
this.Commands.command(this.actionName, this.argumentOne, this.argumentTwo); | ||
@@ -176,4 +176,4 @@ }); | ||
it('should always return the instance of Commands from `reactOnce`', function() { | ||
expect(this.reactOnceSpy) | ||
it('should always return the instance of Commands from `complyOnce`', function() { | ||
expect(this.complyOnceSpy) | ||
.to.have.been.calledOnce | ||
@@ -191,11 +191,11 @@ .and.to.have.always.returned(this.Commands); | ||
this.actionName = 'actionOne'; | ||
this.stopReacting = _.partial(this.Commands.stopReacting, this.actionName); | ||
this.stopComplying = _.partial(this.Commands.stopComplying, this.actionName); | ||
}); | ||
it('should not throw an Error.', function() { | ||
expect(this.stopReacting).to.not.throw(Error); | ||
expect(this.stopComplying).to.not.throw(Error); | ||
}); | ||
}); | ||
describe('when calling stopReacting from a Commands instance', function() { | ||
describe('when calling stopComplying from a Commands instance', function() { | ||
beforeEach(function() { | ||
@@ -206,5 +206,5 @@ this.commandOne = 'commandOne'; | ||
this.commandTwoStub = this.sinon.stub(); | ||
this.Commands.react(this.commandOne, this.commandOneStub); | ||
this.Commands.react(this.commandTwo, this.commandTwoStub); | ||
this.Commands.stopReacting(); | ||
this.Commands.comply(this.commandOne, this.commandOneStub); | ||
this.Commands.comply(this.commandTwo, this.commandTwoStub); | ||
this.Commands.stopComplying(); | ||
}); | ||
@@ -216,4 +216,4 @@ | ||
it('should return the instance of Commands from stopReacting', function() { | ||
expect(this.stopReactingSpy).to.have.always.returned(this.Commands); | ||
it('should return the instance of Commands from stopComplying', function() { | ||
expect(this.stopComplyingSpy).to.have.always.returned(this.Commands); | ||
}); | ||
@@ -220,0 +220,0 @@ |
@@ -43,3 +43,3 @@ describe('DEBUG mode:', function() { | ||
it('should log a console warning when unregistering a command that was never registered on a channel', function() { | ||
this.channel.stopReacting(this.eventName); | ||
this.channel.stopComplying(this.eventName); | ||
var warning = 'Attempted to remove the unregistered command "' + this.eventName + '" on the myChannel channel.'; | ||
@@ -56,3 +56,3 @@ expect(this.consoleStub).to.have.been.calledOnce.and.calledWithExactly(warning); | ||
it('should log a console warning when unregistering a command that was never registered on an object', function() { | ||
this.Commands.stopReacting(this.eventName); | ||
this.Commands.stopComplying(this.eventName); | ||
var warning = 'Attempted to remove the unregistered command "' + this.eventName + '"'; | ||
@@ -91,3 +91,3 @@ expect(this.consoleStub).to.have.been.calledOnce.and.calledWithExactly(warning); | ||
it('should not log a console warning when unregistering a command that was never registered on a channel', function() { | ||
this.channel.stopReacting(this.eventName); | ||
this.channel.stopComplying(this.eventName); | ||
expect(this.consoleStub).to.not.have.been.called; | ||
@@ -102,3 +102,3 @@ }); | ||
it('should not log a console warning when unregistering a command that was never registered on an object', function() { | ||
this.Commands.stopReacting(this.eventName); | ||
this.Commands.stopComplying(this.eventName); | ||
expect(this.consoleStub).to.not.have.been.called; | ||
@@ -105,0 +105,0 @@ }); |
@@ -11,5 +11,5 @@ describe('Top-level API:', function() { | ||
beforeEach(function() { | ||
Backbone.Radio.react(this.channelName, this.eventName, 'firstArg1', 'secondArg1'); | ||
Backbone.Radio.reactOnce(this.channelName, this.eventName, 'firstArg2', 'secondArg2'); | ||
Backbone.Radio.stopReacting(this.channelName, this.eventName, 'firstArg3', 'secondArg3'); | ||
Backbone.Radio.comply(this.channelName, this.eventName, 'firstArg1', 'secondArg1'); | ||
Backbone.Radio.complyOnce(this.channelName, this.eventName, 'firstArg2', 'secondArg2'); | ||
Backbone.Radio.stopComplying(this.channelName, this.eventName, 'firstArg3', 'secondArg3'); | ||
Backbone.Radio.command(this.channelName, this.eventName, 'firstArg4', 'secondArg4'); | ||
@@ -19,3 +19,3 @@ }); | ||
it('should execute each method on the proper channel with the arguments.', function() { | ||
expect(this.channelStub.react) | ||
expect(this.channelStub.comply) | ||
.to.have.been.calledOnce | ||
@@ -25,3 +25,3 @@ .and.to.have.been.calledOn(this.channel) | ||
expect(this.channelStub.reactOnce) | ||
expect(this.channelStub.complyOnce) | ||
.to.have.been.calledOnce | ||
@@ -31,3 +31,3 @@ .and.to.have.been.calledOn(this.channel) | ||
expect(this.channelStub.stopReacting) | ||
expect(this.channelStub.stopComplying) | ||
.to.have.been.calledOnce | ||
@@ -67,3 +67,3 @@ .and.to.have.been.calledOn(this.channel) | ||
.and.calledWithExactly('firstArg3', 'secondArg3'); | ||
expect(this.channelStub.request) | ||
@@ -70,0 +70,0 @@ .to.have.been.calledOnce |
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
85753
33
1524
341