From 8d3c7deec61205daddbd49ce86dbac27afb1aaad Mon Sep 17 00:00:00 2001 From: Andrew Humphreys Date: Tue, 23 Aug 2016 10:47:25 +0100 Subject: [PATCH] 2.0.0 (#263) * Move BB and _ to peerDependencies * Bump and Build 2.0.0-pre.1 * Update changelog * * peerDependency update Backbone ^1.3.3 and underscore ^1.8.3 * dependencies Backbone >=1.3.3 <1.4.0 and underscore ^1.8.3 * Bump and build 2.0.0-pre.2 * 2.0.0-pre.2 * Bump and Build 2.0.0 * Modify travis matrix * Lock down devDependencies --- .travis.yml | 12 +---- CHANGELOG.md | 13 ++++++ README.md | 2 + bower.json | 8 +--- build/backbone.radio.js | 10 ++-- build/backbone.radio.js.map | 2 +- build/backbone.radio.min.js | 4 +- build/backbone.radio.min.js.map | 3 +- package.json | 81 +++++++++++++++++---------------- 9 files changed, 68 insertions(+), 67 deletions(-) diff --git a/.travis.yml b/.travis.yml index 76ff469..a39adec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,17 +7,7 @@ cache: - node_modules matrix: include: - - env: UNDERSCORE=1.4.4 BACKBONE=1.0 - - env: UNDERSCORE=1.5 BACKBONE=1.0 - - env: UNDERSCORE=1.7 BACKBONE=1.2.3 - - env: UNDERSCORE=1.7 BACKBONE=1.1 - - env: UNDERSCORE=1.7 BACKBONE=1.0 - - env: UNDERSCORE=1.6 BACKBONE=1.0 - - env: UNDERSCORE=1.4.4 BACKBONE=1.1.0 - - env: UNDERSCORE=1.5 BACKBONE=1.1 - - env: UNDERSCORE=1.8 BACKBONE=1.2.3 - - env: UNDERSCORE=1.8 BACKBONE=1.3.2 - - env: LODASH=2.4 BACKBONE=1.1 + - env: UNDERSCORE=1.8 BACKBONE=1.3 - env: LODASH=2.4 BACKBONE=1.3 env: MAINRUN=true before_install: diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a4426d..b5f1e6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +### [2.0.0](https://github.com/marionettejs/backbone.radio/releases/tag/2.0.0) + +- Updated Backbone and Underscore version ranges. +- Moved Backbone and Underscore to peerDependencies. + +### [2.0.0-pre.2](https://github.com/marionettejs/backbone.radio/releases/tag/2.0.0-pre.2) + +- Updated Backbone and Underscore version ranges. + +### [2.0.0-pre.1](https://github.com/marionettejs/backbone.radio/releases/tag/2.0.0-pre.1) + +- Moved Backbone and Underscore to peerDependencies. + ### [1.0.5](https://github.com/marionettejs/backbone.radio/releases/tag/1.0.5) - Updated Backbone dep to allow v1.3.3 diff --git a/README.md b/README.md index 38da5d7..0eec8c1 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,8 @@ bower install backbone.radio npm install backbone.radio ``` +You must also ensure that Backbone.Radio's dependencies on Underscore (or Lodash) and Backbone are installed. + ## Documentation - [Getting Started](#getting-started) diff --git a/bower.json b/bower.json index 017815a..6ec053e 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "backbone.radio", - "version": "1.0.5", + "version": "2.0.0", "homepage": "https://github.com/marionettejs/backbone.radio", "authors": [ "Jmeas " @@ -25,9 +25,5 @@ "bower_components", "test", "tests" - ], - "dependencies": { - "backbone": "1.0.0 - 1.3.x", - "underscore": "1.4.4 - 1.8.3" - } + ] } diff --git a/build/backbone.radio.js b/build/backbone.radio.js index d160d9c..b95fc47 100644 --- a/build/backbone.radio.js +++ b/build/backbone.radio.js @@ -1,4 +1,4 @@ -// Backbone.Radio v1.0.4 +// Backbone.Radio v2.0.0 (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('underscore'), require('backbone')) : @@ -9,19 +9,17 @@ _ = 'default' in _ ? _['default'] : _; Backbone = 'default' in Backbone ? Backbone['default'] : Backbone; - var babelHelpers = {}; - babelHelpers.typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; - babelHelpers; var previousRadio = Backbone.Radio; var Radio = Backbone.Radio = {}; - Radio.VERSION = '1.0.4'; + Radio.VERSION = '2.0.0'; // This allows you to run multiple instances of Radio on the same // webapp. After loading the new version, call `noConflict()` to @@ -65,7 +63,7 @@ var results = {}; // Handle event maps. - if ((typeof name === 'undefined' ? 'undefined' : babelHelpers.typeof(name)) === 'object') { + if ((typeof name === 'undefined' ? 'undefined' : _typeof(name)) === 'object') { for (var key in name) { var result = obj[action].apply(obj, [key, name[key]].concat(rest)); eventSplitter.test(key) ? _.extend(results, result) : results[key] = result; diff --git a/build/backbone.radio.js.map b/build/backbone.radio.js.map index 44f9f58..feb2e83 100644 --- a/build/backbone.radio.js.map +++ b/build/backbone.radio.js.map @@ -1 +1 @@ -{"version":3,"names":[],"mappings":"","sources":["backbone.radio.js"],"sourcesContent":["// Backbone.Radio v1.0.4\n\n(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('underscore'), require('backbone')) :\n typeof define === 'function' && define.amd ? define(['underscore', 'backbone'], factory) :\n (global.Backbone = global.Backbone || {}, global.Backbone.Radio = factory(global._,global.Backbone));\n}(this, function (_,Backbone) { 'use strict';\n\n _ = 'default' in _ ? _['default'] : _;\n Backbone = 'default' in Backbone ? Backbone['default'] : Backbone;\n\n var babelHelpers = {};\n babelHelpers.typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) {\n return typeof obj;\n } : function (obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n };\n babelHelpers;\n\n var previousRadio = Backbone.Radio;\n\n var Radio = Backbone.Radio = {};\n\n Radio.VERSION = '1.0.4';\n\n // This allows you to run multiple instances of Radio on the same\n // webapp. After loading the new version, call `noConflict()` to\n // get a reference to it. At the same time the old version will be\n // returned to Backbone.Radio.\n Radio.noConflict = function () {\n Backbone.Radio = previousRadio;\n return this;\n };\n\n // Whether or not we're in DEBUG mode or not. DEBUG mode helps you\n // get around the issues of lack of warnings when events are mis-typed.\n Radio.DEBUG = false;\n\n // Format debug text.\n Radio._debugText = function (warning, eventName, channelName) {\n return warning + (channelName ? ' on the ' + channelName + ' channel' : '') + ': \"' + eventName + '\"';\n };\n\n // This is the method that's called when an unregistered event was called.\n // By default, it logs warning to the console. By overriding this you could\n // make it throw an Error, for instance. This would make firing a nonexistent event\n // have the same consequence as firing a nonexistent method on an Object.\n Radio.debugLog = function (warning, eventName, channelName) {\n if (Radio.DEBUG && console && console.warn) {\n console.warn(Radio._debugText(warning, eventName, channelName));\n }\n };\n\n var eventSplitter = /\\s+/;\n\n // An internal method used to handle Radio's method overloading for Requests.\n // It's borrowed from Backbone.Events. It differs from Backbone's overload\n // API (which is used in Backbone.Events) in that it doesn't support space-separated\n // event names.\n Radio._eventsApi = function (obj, action, name, rest) {\n if (!name) {\n return false;\n }\n\n var results = {};\n\n // Handle event maps.\n if ((typeof name === 'undefined' ? 'undefined' : babelHelpers.typeof(name)) === 'object') {\n for (var key in name) {\n var result = obj[action].apply(obj, [key, name[key]].concat(rest));\n eventSplitter.test(key) ? _.extend(results, result) : results[key] = result;\n }\n return results;\n }\n\n // Handle space separated event names.\n if (eventSplitter.test(name)) {\n var names = name.split(eventSplitter);\n for (var i = 0, l = names.length; i < l; i++) {\n results[names[i]] = obj[action].apply(obj, [names[i]].concat(rest));\n }\n return results;\n }\n\n return false;\n };\n\n // An optimized way to execute callbacks.\n Radio._callHandler = function (callback, context, args) {\n var a1 = args[0],\n a2 = args[1],\n a3 = args[2];\n switch (args.length) {\n case 0:\n return callback.call(context);\n case 1:\n return callback.call(context, a1);\n case 2:\n return callback.call(context, a1, a2);\n case 3:\n return callback.call(context, a1, a2, a3);\n default:\n return callback.apply(context, args);\n }\n };\n\n // A helper used by `off` methods to the handler from the store\n function removeHandler(store, name, callback, context) {\n var event = store[name];\n if ((!callback || callback === event.callback || callback === event.callback._callback) && (!context || context === event.context)) {\n delete store[name];\n return true;\n }\n }\n\n function removeHandlers(store, name, callback, context) {\n store || (store = {});\n var names = name ? [name] : _.keys(store);\n var matched = false;\n\n for (var i = 0, length = names.length; i < length; i++) {\n name = names[i];\n\n // If there's no event by this name, log it and continue\n // with the loop\n if (!store[name]) {\n continue;\n }\n\n if (removeHandler(store, name, callback, context)) {\n matched = true;\n }\n }\n\n return matched;\n }\n\n /*\n * tune-in\n * -------\n * Get console logs of a channel's activity\n *\n */\n\n var _logs = {};\n\n // This is to produce an identical function in both tuneIn and tuneOut,\n // so that Backbone.Events unregisters it.\n function _partial(channelName) {\n return _logs[channelName] || (_logs[channelName] = _.bind(Radio.log, Radio, channelName));\n }\n\n _.extend(Radio, {\n\n // Log information about the channel and event\n log: function log(channelName, eventName) {\n if (typeof console === 'undefined') {\n return;\n }\n var args = _.toArray(arguments).slice(2);\n console.log('[' + channelName + '] \"' + eventName + '\"', args);\n },\n\n // Logs all events on this channel to the console. It sets an\n // internal value on the channel telling it we're listening,\n // then sets a listener on the Backbone.Events\n tuneIn: function tuneIn(channelName) {\n var channel = Radio.channel(channelName);\n channel._tunedIn = true;\n channel.on('all', _partial(channelName));\n return this;\n },\n\n // Stop logging all of the activities on this channel to the console\n tuneOut: function tuneOut(channelName) {\n var channel = Radio.channel(channelName);\n channel._tunedIn = false;\n channel.off('all', _partial(channelName));\n delete _logs[channelName];\n return this;\n }\n });\n\n /*\n * Backbone.Radio.Requests\n * -----------------------\n * A messaging system for requesting data.\n *\n */\n\n function makeCallback(callback) {\n return _.isFunction(callback) ? callback : function () {\n return callback;\n };\n }\n\n Radio.Requests = {\n\n // Make a request\n request: function request(name) {\n var args = _.toArray(arguments).slice(1);\n var results = Radio._eventsApi(this, 'request', name, args);\n if (results) {\n return results;\n }\n var channelName = this.channelName;\n var requests = this._requests;\n\n // Check if we should log the request, and if so, do it\n if (channelName && this._tunedIn) {\n Radio.log.apply(this, [channelName, name].concat(args));\n }\n\n // If the request isn't handled, log it in DEBUG mode and exit\n if (requests && (requests[name] || requests['default'])) {\n var handler = requests[name] || requests['default'];\n args = requests[name] ? args : arguments;\n return Radio._callHandler(handler.callback, handler.context, args);\n } else {\n Radio.debugLog('An unhandled request was fired', name, channelName);\n }\n },\n\n // Set up a handler for a request\n reply: function reply(name, callback, context) {\n if (Radio._eventsApi(this, 'reply', name, [callback, context])) {\n return this;\n }\n\n this._requests || (this._requests = {});\n\n if (this._requests[name]) {\n Radio.debugLog('A request was overwritten', name, this.channelName);\n }\n\n this._requests[name] = {\n callback: makeCallback(callback),\n context: context || this\n };\n\n return this;\n },\n\n // Set up a handler that can only be requested once\n replyOnce: function replyOnce(name, callback, context) {\n if (Radio._eventsApi(this, 'replyOnce', name, [callback, context])) {\n return this;\n }\n\n var self = this;\n\n var once = _.once(function () {\n self.stopReplying(name);\n return makeCallback(callback).apply(this, arguments);\n });\n\n return this.reply(name, once, context);\n },\n\n // Remove handler(s)\n stopReplying: function stopReplying(name, callback, context) {\n if (Radio._eventsApi(this, 'stopReplying', name)) {\n return this;\n }\n\n // Remove everything if there are no arguments passed\n if (!name && !callback && !context) {\n delete this._requests;\n } else if (!removeHandlers(this._requests, name, callback, context)) {\n Radio.debugLog('Attempted to remove the unregistered request', name, this.channelName);\n }\n\n return this;\n }\n };\n\n /*\n * Backbone.Radio.channel\n * ----------------------\n * Get a reference to a channel by name.\n *\n */\n\n Radio._channels = {};\n\n Radio.channel = function (channelName) {\n if (!channelName) {\n throw new Error('You must provide a name for the channel.');\n }\n\n if (Radio._channels[channelName]) {\n return Radio._channels[channelName];\n } else {\n return Radio._channels[channelName] = new Radio.Channel(channelName);\n }\n };\n\n /*\n * Backbone.Radio.Channel\n * ----------------------\n * A Channel is an object that extends from Backbone.Events,\n * and Radio.Requests.\n *\n */\n\n Radio.Channel = function (channelName) {\n this.channelName = channelName;\n };\n\n _.extend(Radio.Channel.prototype, Backbone.Events, Radio.Requests, {\n\n // Remove all handlers from the messaging systems of this channel\n reset: function reset() {\n this.off();\n this.stopListening();\n this.stopReplying();\n return this;\n }\n });\n\n /*\n * Top-level API\n * -------------\n * Supplies the 'top-level API' for working with Channels directly\n * from Backbone.Radio.\n *\n */\n\n var channel;\n var args;\n var systems = [Backbone.Events, Radio.Requests];\n _.each(systems, function (system) {\n _.each(system, function (method, methodName) {\n Radio[methodName] = function (channelName) {\n args = _.toArray(arguments).slice(1);\n channel = this.channel(channelName);\n return channel[methodName].apply(channel, args);\n };\n });\n });\n\n Radio.reset = function (channelName) {\n var channels = !channelName ? this._channels : [this._channels[channelName]];\n _.each(channels, function (channel) {\n channel.reset();\n });\n };\n\n return Radio;\n\n}));\n"],"file":"backbone.radio.js","sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"names":[],"mappings":"","sources":["backbone.radio.js"],"sourcesContent":["// Backbone.Radio v2.0.0\n\n(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('underscore'), require('backbone')) :\n typeof define === 'function' && define.amd ? define(['underscore', 'backbone'], factory) :\n (global.Backbone = global.Backbone || {}, global.Backbone.Radio = factory(global._,global.Backbone));\n}(this, function (_,Backbone) { 'use strict';\n\n _ = 'default' in _ ? _['default'] : _;\n Backbone = 'default' in Backbone ? Backbone['default'] : Backbone;\n\n var _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) {\n return typeof obj;\n } : function (obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n };\n\n var previousRadio = Backbone.Radio;\n\n var Radio = Backbone.Radio = {};\n\n Radio.VERSION = '2.0.0';\n\n // This allows you to run multiple instances of Radio on the same\n // webapp. After loading the new version, call `noConflict()` to\n // get a reference to it. At the same time the old version will be\n // returned to Backbone.Radio.\n Radio.noConflict = function () {\n Backbone.Radio = previousRadio;\n return this;\n };\n\n // Whether or not we're in DEBUG mode or not. DEBUG mode helps you\n // get around the issues of lack of warnings when events are mis-typed.\n Radio.DEBUG = false;\n\n // Format debug text.\n Radio._debugText = function (warning, eventName, channelName) {\n return warning + (channelName ? ' on the ' + channelName + ' channel' : '') + ': \"' + eventName + '\"';\n };\n\n // This is the method that's called when an unregistered event was called.\n // By default, it logs warning to the console. By overriding this you could\n // make it throw an Error, for instance. This would make firing a nonexistent event\n // have the same consequence as firing a nonexistent method on an Object.\n Radio.debugLog = function (warning, eventName, channelName) {\n if (Radio.DEBUG && console && console.warn) {\n console.warn(Radio._debugText(warning, eventName, channelName));\n }\n };\n\n var eventSplitter = /\\s+/;\n\n // An internal method used to handle Radio's method overloading for Requests.\n // It's borrowed from Backbone.Events. It differs from Backbone's overload\n // API (which is used in Backbone.Events) in that it doesn't support space-separated\n // event names.\n Radio._eventsApi = function (obj, action, name, rest) {\n if (!name) {\n return false;\n }\n\n var results = {};\n\n // Handle event maps.\n if ((typeof name === 'undefined' ? 'undefined' : _typeof(name)) === 'object') {\n for (var key in name) {\n var result = obj[action].apply(obj, [key, name[key]].concat(rest));\n eventSplitter.test(key) ? _.extend(results, result) : results[key] = result;\n }\n return results;\n }\n\n // Handle space separated event names.\n if (eventSplitter.test(name)) {\n var names = name.split(eventSplitter);\n for (var i = 0, l = names.length; i < l; i++) {\n results[names[i]] = obj[action].apply(obj, [names[i]].concat(rest));\n }\n return results;\n }\n\n return false;\n };\n\n // An optimized way to execute callbacks.\n Radio._callHandler = function (callback, context, args) {\n var a1 = args[0],\n a2 = args[1],\n a3 = args[2];\n switch (args.length) {\n case 0:\n return callback.call(context);\n case 1:\n return callback.call(context, a1);\n case 2:\n return callback.call(context, a1, a2);\n case 3:\n return callback.call(context, a1, a2, a3);\n default:\n return callback.apply(context, args);\n }\n };\n\n // A helper used by `off` methods to the handler from the store\n function removeHandler(store, name, callback, context) {\n var event = store[name];\n if ((!callback || callback === event.callback || callback === event.callback._callback) && (!context || context === event.context)) {\n delete store[name];\n return true;\n }\n }\n\n function removeHandlers(store, name, callback, context) {\n store || (store = {});\n var names = name ? [name] : _.keys(store);\n var matched = false;\n\n for (var i = 0, length = names.length; i < length; i++) {\n name = names[i];\n\n // If there's no event by this name, log it and continue\n // with the loop\n if (!store[name]) {\n continue;\n }\n\n if (removeHandler(store, name, callback, context)) {\n matched = true;\n }\n }\n\n return matched;\n }\n\n /*\n * tune-in\n * -------\n * Get console logs of a channel's activity\n *\n */\n\n var _logs = {};\n\n // This is to produce an identical function in both tuneIn and tuneOut,\n // so that Backbone.Events unregisters it.\n function _partial(channelName) {\n return _logs[channelName] || (_logs[channelName] = _.bind(Radio.log, Radio, channelName));\n }\n\n _.extend(Radio, {\n\n // Log information about the channel and event\n log: function log(channelName, eventName) {\n if (typeof console === 'undefined') {\n return;\n }\n var args = _.toArray(arguments).slice(2);\n console.log('[' + channelName + '] \"' + eventName + '\"', args);\n },\n\n // Logs all events on this channel to the console. It sets an\n // internal value on the channel telling it we're listening,\n // then sets a listener on the Backbone.Events\n tuneIn: function tuneIn(channelName) {\n var channel = Radio.channel(channelName);\n channel._tunedIn = true;\n channel.on('all', _partial(channelName));\n return this;\n },\n\n // Stop logging all of the activities on this channel to the console\n tuneOut: function tuneOut(channelName) {\n var channel = Radio.channel(channelName);\n channel._tunedIn = false;\n channel.off('all', _partial(channelName));\n delete _logs[channelName];\n return this;\n }\n });\n\n /*\n * Backbone.Radio.Requests\n * -----------------------\n * A messaging system for requesting data.\n *\n */\n\n function makeCallback(callback) {\n return _.isFunction(callback) ? callback : function () {\n return callback;\n };\n }\n\n Radio.Requests = {\n\n // Make a request\n request: function request(name) {\n var args = _.toArray(arguments).slice(1);\n var results = Radio._eventsApi(this, 'request', name, args);\n if (results) {\n return results;\n }\n var channelName = this.channelName;\n var requests = this._requests;\n\n // Check if we should log the request, and if so, do it\n if (channelName && this._tunedIn) {\n Radio.log.apply(this, [channelName, name].concat(args));\n }\n\n // If the request isn't handled, log it in DEBUG mode and exit\n if (requests && (requests[name] || requests['default'])) {\n var handler = requests[name] || requests['default'];\n args = requests[name] ? args : arguments;\n return Radio._callHandler(handler.callback, handler.context, args);\n } else {\n Radio.debugLog('An unhandled request was fired', name, channelName);\n }\n },\n\n // Set up a handler for a request\n reply: function reply(name, callback, context) {\n if (Radio._eventsApi(this, 'reply', name, [callback, context])) {\n return this;\n }\n\n this._requests || (this._requests = {});\n\n if (this._requests[name]) {\n Radio.debugLog('A request was overwritten', name, this.channelName);\n }\n\n this._requests[name] = {\n callback: makeCallback(callback),\n context: context || this\n };\n\n return this;\n },\n\n // Set up a handler that can only be requested once\n replyOnce: function replyOnce(name, callback, context) {\n if (Radio._eventsApi(this, 'replyOnce', name, [callback, context])) {\n return this;\n }\n\n var self = this;\n\n var once = _.once(function () {\n self.stopReplying(name);\n return makeCallback(callback).apply(this, arguments);\n });\n\n return this.reply(name, once, context);\n },\n\n // Remove handler(s)\n stopReplying: function stopReplying(name, callback, context) {\n if (Radio._eventsApi(this, 'stopReplying', name)) {\n return this;\n }\n\n // Remove everything if there are no arguments passed\n if (!name && !callback && !context) {\n delete this._requests;\n } else if (!removeHandlers(this._requests, name, callback, context)) {\n Radio.debugLog('Attempted to remove the unregistered request', name, this.channelName);\n }\n\n return this;\n }\n };\n\n /*\n * Backbone.Radio.channel\n * ----------------------\n * Get a reference to a channel by name.\n *\n */\n\n Radio._channels = {};\n\n Radio.channel = function (channelName) {\n if (!channelName) {\n throw new Error('You must provide a name for the channel.');\n }\n\n if (Radio._channels[channelName]) {\n return Radio._channels[channelName];\n } else {\n return Radio._channels[channelName] = new Radio.Channel(channelName);\n }\n };\n\n /*\n * Backbone.Radio.Channel\n * ----------------------\n * A Channel is an object that extends from Backbone.Events,\n * and Radio.Requests.\n *\n */\n\n Radio.Channel = function (channelName) {\n this.channelName = channelName;\n };\n\n _.extend(Radio.Channel.prototype, Backbone.Events, Radio.Requests, {\n\n // Remove all handlers from the messaging systems of this channel\n reset: function reset() {\n this.off();\n this.stopListening();\n this.stopReplying();\n return this;\n }\n });\n\n /*\n * Top-level API\n * -------------\n * Supplies the 'top-level API' for working with Channels directly\n * from Backbone.Radio.\n *\n */\n\n var channel;\n var args;\n var systems = [Backbone.Events, Radio.Requests];\n _.each(systems, function (system) {\n _.each(system, function (method, methodName) {\n Radio[methodName] = function (channelName) {\n args = _.toArray(arguments).slice(1);\n channel = this.channel(channelName);\n return channel[methodName].apply(channel, args);\n };\n });\n });\n\n Radio.reset = function (channelName) {\n var channels = !channelName ? this._channels : [this._channels[channelName]];\n _.each(channels, function (channel) {\n channel.reset();\n });\n };\n\n return Radio;\n\n}));\n"],"file":"backbone.radio.js","sourceRoot":"/source/"} \ No newline at end of file diff --git a/build/backbone.radio.min.js b/build/backbone.radio.min.js index 93d129c..7fa28b0 100644 --- a/build/backbone.radio.min.js +++ b/build/backbone.radio.min.js @@ -1,3 +1,3 @@ -// Backbone.Radio v1.0.4 -!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("underscore"),require("backbone")):"function"==typeof define&&define.amd?define(["underscore","backbone"],n):(e.Backbone=e.Backbone||{},e.Backbone.Radio=n(e._,e.Backbone))}(this,function(e,n){"use strict";function t(e,n,t,r){var o=e[n];return t&&t!==o.callback&&t!==o.callback._callback||r&&r!==o.context?void 0:(delete e[n],!0)}function r(n,r,o,i){n||(n={});for(var s=r?[r]:e.keys(n),u=!1,a=0,c=s.length;c>a;a++)r=s[a],n[r]&&t(n,r,o,i)&&(u=!0);return u}function o(n){return l[n]||(l[n]=e.bind(a.log,a,n))}function i(n){return e.isFunction(n)?n:function(){return n}}e="default"in e?e["default"]:e,n="default"in n?n["default"]:n;var s={};s["typeof"]="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};var u=n.Radio,a=n.Radio={};a.VERSION="1.0.4",a.noConflict=function(){return n.Radio=u,this},a.DEBUG=!1,a._debugText=function(e,n,t){return e+(t?" on the "+t+" channel":"")+': "'+n+'"'},a.debugLog=function(e,n,t){a.DEBUG&&console&&console.warn&&console.warn(a._debugText(e,n,t))};var c=/\s+/;a._eventsApi=function(n,t,r,o){if(!r)return!1;var i={};if("object"===("undefined"==typeof r?"undefined":s["typeof"](r))){for(var u in r){var a=n[t].apply(n,[u,r[u]].concat(o));c.test(u)?e.extend(i,a):i[u]=a}return i}if(c.test(r)){for(var l=r.split(c),f=0,h=l.length;h>f;f++)i[l[f]]=n[t].apply(n,[l[f]].concat(o));return i}return!1},a._callHandler=function(e,n,t){var r=t[0],o=t[1],i=t[2];switch(t.length){case 0:return e.call(n);case 1:return e.call(n,r);case 2:return e.call(n,r,o);case 3:return e.call(n,r,o,i);default:return e.apply(n,t)}};var l={};e.extend(a,{log:function(n,t){if("undefined"!=typeof console){var r=e.toArray(arguments).slice(2);console.log("["+n+'] "'+t+'"',r)}},tuneIn:function(e){var n=a.channel(e);return n._tunedIn=!0,n.on("all",o(e)),this},tuneOut:function(e){var n=a.channel(e);return n._tunedIn=!1,n.off("all",o(e)),delete l[e],this}}),a.Requests={request:function(n){var t=e.toArray(arguments).slice(1),r=a._eventsApi(this,"request",n,t);if(r)return r;var o=this.channelName,i=this._requests;if(o&&this._tunedIn&&a.log.apply(this,[o,n].concat(t)),i&&(i[n]||i["default"])){var s=i[n]||i["default"];return t=i[n]?t:arguments,a._callHandler(s.callback,s.context,t)}a.debugLog("An unhandled request was fired",n,o)},reply:function(e,n,t){return a._eventsApi(this,"reply",e,[n,t])?this:(this._requests||(this._requests={}),this._requests[e]&&a.debugLog("A request was overwritten",e,this.channelName),this._requests[e]={callback:i(n),context:t||this},this)},replyOnce:function(n,t,r){if(a._eventsApi(this,"replyOnce",n,[t,r]))return this;var o=this,s=e.once(function(){return o.stopReplying(n),i(t).apply(this,arguments)});return this.reply(n,s,r)},stopReplying:function(e,n,t){return a._eventsApi(this,"stopReplying",e)?this:(e||n||t?r(this._requests,e,n,t)||a.debugLog("Attempted to remove the unregistered request",e,this.channelName):delete this._requests,this)}},a._channels={},a.channel=function(e){if(!e)throw new Error("You must provide a name for the channel.");return a._channels[e]?a._channels[e]:a._channels[e]=new a.Channel(e)},a.Channel=function(e){this.channelName=e},e.extend(a.Channel.prototype,n.Events,a.Requests,{reset:function(){return this.off(),this.stopListening(),this.stopReplying(),this}});var f,h,d=[n.Events,a.Requests];return e.each(d,function(n){e.each(n,function(n,t){a[t]=function(n){return h=e.toArray(arguments).slice(1),f=this.channel(n),f[t].apply(f,h)}})}),a.reset=function(n){var t=n?[this._channels[n]]:this._channels;e.each(t,function(e){e.reset()})},a}); +// Backbone.Radio v2.0.0 +!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("underscore"),require("backbone")):"function"==typeof define&&define.amd?define(["underscore","backbone"],n):(e.Backbone=e.Backbone||{},e.Backbone.Radio=n(e._,e.Backbone))}(this,function(e,n){"use strict";function t(e,n,t,r){var o=e[n];if(!(t&&t!==o.callback&&t!==o.callback._callback||r&&r!==o.context))return delete e[n],!0}function r(n,r,o,i){n||(n={});for(var s=r?[r]:e.keys(n),u=!1,c=0,a=s.length;c=1.3.3 <1.4.0", + "chai": "3.4.1", + "del": "2.2.0", + "eslint": "3.2.2", + "glob": "6.0.3", + "gulp": "3.9.0", + "gulp-eslint": "3.0.1", + "gulp-file": "0.2.0", + "gulp-filter": "3.0.0", + "gulp-header": "1.7.1", + "gulp-istanbul": "0.10.3", + "gulp-jscs": "3.0.0", + "gulp-livereload": "3.8.1", + "gulp-load-plugins": "1.1.0", + "gulp-mocha": "2.2.0", + "gulp-plumber": "1.0.1", + "gulp-rename": "1.2.2", + "gulp-sourcemaps": "1.6.0", + "gulp-uglify": "1.5.1", + "gulp-util": "3.0.7", + "isparta": "4.0.0", + "json-loader": "0.5.3", + "mkdirp": "0.5.1", + "mocha": "2.3.4", + "rollup": "0.25.4", + "rollup-plugin-babel": "2.4.0", + "sinon": "1.17.2", + "sinon-chai": "2.8.0", + "underscore": "1.8.3", + "webpack": "1.12.9", + "webpack-stream": "3.1.0" }, "babelBoilerplateOptions": { "entryFileName": "backbone.radio",