diff --git a/dist/reflux.js b/dist/reflux.js index ed0ecf7..29d3105 100644 --- a/dist/reflux.js +++ b/dist/reflux.js @@ -370,11 +370,6 @@ var _ = _dereq_('./utils'), */ module.exports = _.extend({ - /** - * By adding this in the mixin we get error message if other React mixins try to use the same prop - */ - subscriptions: [], - /** * Cleans up all listener previously registered. */ diff --git a/dist/reflux.min.js b/dist/reflux.min.js index 229ed24..d7bc6d3 100644 --- a/dist/reflux.min.js +++ b/dist/reflux.min.js @@ -1 +1 @@ -!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.Reflux=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;gb;b++)d.push(this._events[a][b].fn);return d},d.prototype.emit=function(a,b,c,d,e,f){if(!this._events||!this._events[a])return!1;var g,h,i,j=this._events[a],k=j.length,l=arguments.length,m=j[0];if(1===k){switch(m.once&&this.removeListener(a,m.fn,!0),l){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,b),!0;case 3:return m.fn.call(m.context,b,c),!0;case 4:return m.fn.call(m.context,b,c,d),!0;case 5:return m.fn.call(m.context,b,c,d,e),!0;case 6:return m.fn.call(m.context,b,c,d,e,f),!0}for(h=1,g=new Array(l-1);l>h;h++)g[h-1]=arguments[h];m.fn.apply(m.context,g)}else for(h=0;k>h;h++)switch(j[h].once&&this.removeListener(a,j[h].fn,!0),l){case 1:j[h].fn.call(j[h].context);break;case 2:j[h].fn.call(j[h].context,b);break;case 3:j[h].fn.call(j[h].context,b,c);break;default:if(!g)for(i=1,g=new Array(l-1);l>i;i++)g[i-1]=arguments[i];j[h].fn.apply(j[h].context,g)}return!0},d.prototype.on=function(a,b,d){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),this._events[a].push(new c(b,d||this)),this},d.prototype.once=function(a,b,d){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),this._events[a].push(new c(b,d||this,!0)),this},d.prototype.removeListener=function(a,b,c){if(!this._events||!this._events[a])return this;var d=this._events[a],e=[];if(b)for(var f=0,g=d.length;g>f;f++)d[f].fn!==b&&d[f].once!==c&&e.push(d[f]);return this._events[a]=e.length?e:null,this},d.prototype.removeAllListeners=function(a){return this._events?(a?this._events[a]=null:this._events={},this):this},d.prototype.off=d.prototype.removeListener,d.prototype.addListener=d.prototype.on,d.prototype.setMaxListeners=function(){return this},d.EventEmitter=d,d.EventEmitter2=d,d.EventEmitter3=d,"object"==typeof b&&b.exports&&(b.exports=d)},{}],2:[function(a,b,c){c.createdStores=[],c.createdActions=[],c.reset=function(){for(;c.createdStores.length;)c.createdStores.pop();for(;c.createdActions.length;)c.createdActions.pop()}},{}],3:[function(a,b){var c=a("./utils");b.exports={hasListener:function(a){for(var b,c=0;c<(this.subscriptions||[]).length;++c)if(b=this.subscriptions[c].listenable,b===a||b.hasListener&&b.hasListener(a))return!0;return!1},listenToMany:function(a){for(var b in a){var d=c.callbackName(b),e=this[d]?d:this[b]?b:void 0;e&&this.listenTo(a[b],e,this[d+"Default"]||this[e+"Default"]||e)}},validateListening:function(a){return a===this?"Listener is not able to listen to itself":c.isFunction(a.listen)?this.hasListener(a)?"Listener cannot listen to this listenable because of circular loop":void 0:a+" is missing a listen method"},listenTo:function(a,b,c){var d=this.validateListening(a),e=this;if(d)throw Error(d);this.fetchDefaultData(a,c),this.subscriptions||(this.subscriptions=[]);var f=a.listen(this[b]||b,this),g=function(b){f(),b||e.subscriptions.splice(e.subscriptions.indexOf(a),1)},h={stop:g,listenable:a};return this.subscriptions.push(h),h},stopListeningTo:function(a,b){for(var c=0;c<(this.subscriptions||[]).length;c++)if(this.subscriptions[c].listenable===a)return this.subscriptions[c].stop(b),!0;return!1},stopListeningToAll:function(){(this.subscriptions||[]).forEach(function(a){a.stop(!0)}),this.subscriptions=[]},fetchDefaultData:function(a,b){b=b&&this[b]||b;var d=this;c.isFunction(b)&&c.isFunction(a.getDefaultData)&&(data=a.getDefaultData(),data&&c.isFunction(data.then)?data.then(function(){b.apply(d,arguments)}):b.call(this,data))}}},{"./utils":13}],4:[function(a,b){var c=a("./utils"),d=a("./ListenerMethods");b.exports=c.extend({subscriptions:[],componentWillUnmount:d.stopListeningToAll},d)},{"./ListenerMethods":3,"./utils":13}],5:[function(a,b){var c=a("./utils");b.exports={preEmit:function(){},shouldEmit:function(){return!0},listen:function(a,b){var c=function(c){a.apply(b,c)},d=this;return this.emitter.addListener(this.eventLabel,c),function(){d.emitter.removeListener(d.eventLabel,c)}},trigger:function(){var a=arguments,b=this.preEmit.apply(this,a);a=void 0===b?a:c.isArguments(b)?b:[].concat(b),this.shouldEmit.apply(this,a)&&this.emitter.emit(this.eventLabel,a)},triggerAsync:function(){var a=arguments,b=this;c.nextTick(function(){b.trigger.apply(b,a)})}}},{"./utils":13}],6:[function(a,b){var c=a("./createAction"),d=Array.prototype.slice;b.exports=function(){function a(){g=new Array(i),h=new Array(i)}function b(a){return function(){g[a]=!0,h[a]=d.call(arguments),e()}}function e(){f()&&(j.apply(j,h),a())}function f(){for(var a=0;i>a;a++)if(!g[a])return!1;return!0}var g,h,i=arguments.length,j=c();j.hasListener=function(a){for(var b,c=0;ck;k++)arguments[k].listen(b(k),null);return j}},{"./createAction":8}],7:[function(a,b){var c=a("../src"),d=a("./utils");b.exports=function(a,b){return{componentDidMount:function(){for(var e in c.ListenerMethods)if(this[e]!==c.ListenerMethods[e]){if(this[e])throw"Can't have other property '"+e+"' when using Reflux.listenTo!";this[e]=c.ListenerMethods[e]}var f=this,g=b?function(a){f.setState(d.object([b],[a]))}:this.setState;this.listenTo(a,g,g)},componentWillUnmount:c.ListenerMixin.componentWillUnmount}}},{"../src":10,"./utils":13}],8:[function(a,b){var c=a("./utils"),d=a("../src"),e=a("./Keep");b.exports=function(a){a=a||{};var b=c.extend({eventLabel:"action",emitter:new c.EventEmitter},a,d.PublisherMethods,{preEmit:a.preEmit||d.PublisherMethods.preEmit,shouldEmit:a.shouldEmit||d.PublisherMethods.shouldEmit}),f=function(){b.triggerAsync.apply(b,arguments)};return c.extend(f,b),e.createdActions.push(f),f}},{"../src":10,"./Keep":2,"./utils":13}],9:[function(a,b){var c=a("./utils"),d=a("../src"),e=a("./Keep");b.exports=function(a){function b(){var a,b=0;if(this.subscriptions=[],this.emitter=new c.EventEmitter,this.eventLabel="change",this.init&&c.isFunction(this.init)&&this.init(),this.listenables)for(a=[].concat(this.listenables);be;e++){b=arguments[e];for(c in b)a[c]=b[c]}return a},c.isFunction=function(a){return"function"==typeof a},c.EventEmitter=a("eventemitter3"),c.nextTick=function(a){setTimeout(a,0)},c.callbackName=function(a){return"on"+a.charAt(0).toUpperCase()+a.slice(1)},c.object=function(a,b){for(var c={},d=0;db;b++)d.push(this._events[a][b].fn);return d},d.prototype.emit=function(a,b,c,d,e,f){if(!this._events||!this._events[a])return!1;var g,h,i,j=this._events[a],k=j.length,l=arguments.length,m=j[0];if(1===k){switch(m.once&&this.removeListener(a,m.fn,!0),l){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,b),!0;case 3:return m.fn.call(m.context,b,c),!0;case 4:return m.fn.call(m.context,b,c,d),!0;case 5:return m.fn.call(m.context,b,c,d,e),!0;case 6:return m.fn.call(m.context,b,c,d,e,f),!0}for(h=1,g=new Array(l-1);l>h;h++)g[h-1]=arguments[h];m.fn.apply(m.context,g)}else for(h=0;k>h;h++)switch(j[h].once&&this.removeListener(a,j[h].fn,!0),l){case 1:j[h].fn.call(j[h].context);break;case 2:j[h].fn.call(j[h].context,b);break;case 3:j[h].fn.call(j[h].context,b,c);break;default:if(!g)for(i=1,g=new Array(l-1);l>i;i++)g[i-1]=arguments[i];j[h].fn.apply(j[h].context,g)}return!0},d.prototype.on=function(a,b,d){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),this._events[a].push(new c(b,d||this)),this},d.prototype.once=function(a,b,d){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),this._events[a].push(new c(b,d||this,!0)),this},d.prototype.removeListener=function(a,b,c){if(!this._events||!this._events[a])return this;var d=this._events[a],e=[];if(b)for(var f=0,g=d.length;g>f;f++)d[f].fn!==b&&d[f].once!==c&&e.push(d[f]);return this._events[a]=e.length?e:null,this},d.prototype.removeAllListeners=function(a){return this._events?(a?this._events[a]=null:this._events={},this):this},d.prototype.off=d.prototype.removeListener,d.prototype.addListener=d.prototype.on,d.prototype.setMaxListeners=function(){return this},d.EventEmitter=d,d.EventEmitter2=d,d.EventEmitter3=d,"object"==typeof b&&b.exports&&(b.exports=d)},{}],2:[function(a,b,c){c.createdStores=[],c.createdActions=[],c.reset=function(){for(;c.createdStores.length;)c.createdStores.pop();for(;c.createdActions.length;)c.createdActions.pop()}},{}],3:[function(a,b){var c=a("./utils");b.exports={hasListener:function(a){for(var b,c=0;c<(this.subscriptions||[]).length;++c)if(b=this.subscriptions[c].listenable,b===a||b.hasListener&&b.hasListener(a))return!0;return!1},listenToMany:function(a){for(var b in a){var d=c.callbackName(b),e=this[d]?d:this[b]?b:void 0;e&&this.listenTo(a[b],e,this[d+"Default"]||this[e+"Default"]||e)}},validateListening:function(a){return a===this?"Listener is not able to listen to itself":c.isFunction(a.listen)?this.hasListener(a)?"Listener cannot listen to this listenable because of circular loop":void 0:a+" is missing a listen method"},listenTo:function(a,b,c){var d=this.validateListening(a),e=this;if(d)throw Error(d);this.fetchDefaultData(a,c),this.subscriptions||(this.subscriptions=[]);var f=a.listen(this[b]||b,this),g=function(b){f(),b||e.subscriptions.splice(e.subscriptions.indexOf(a),1)},h={stop:g,listenable:a};return this.subscriptions.push(h),h},stopListeningTo:function(a,b){for(var c=0;c<(this.subscriptions||[]).length;c++)if(this.subscriptions[c].listenable===a)return this.subscriptions[c].stop(b),!0;return!1},stopListeningToAll:function(){(this.subscriptions||[]).forEach(function(a){a.stop(!0)}),this.subscriptions=[]},fetchDefaultData:function(a,b){b=b&&this[b]||b;var d=this;c.isFunction(b)&&c.isFunction(a.getDefaultData)&&(data=a.getDefaultData(),data&&c.isFunction(data.then)?data.then(function(){b.apply(d,arguments)}):b.call(this,data))}}},{"./utils":13}],4:[function(a,b){var c=a("./utils"),d=a("./ListenerMethods");b.exports=c.extend({componentWillUnmount:d.stopListeningToAll},d)},{"./ListenerMethods":3,"./utils":13}],5:[function(a,b){var c=a("./utils");b.exports={preEmit:function(){},shouldEmit:function(){return!0},listen:function(a,b){var c=function(c){a.apply(b,c)},d=this;return this.emitter.addListener(this.eventLabel,c),function(){d.emitter.removeListener(d.eventLabel,c)}},trigger:function(){var a=arguments,b=this.preEmit.apply(this,a);a=void 0===b?a:c.isArguments(b)?b:[].concat(b),this.shouldEmit.apply(this,a)&&this.emitter.emit(this.eventLabel,a)},triggerAsync:function(){var a=arguments,b=this;c.nextTick(function(){b.trigger.apply(b,a)})}}},{"./utils":13}],6:[function(a,b){var c=a("./createAction"),d=Array.prototype.slice;b.exports=function(){function a(){g=new Array(i),h=new Array(i)}function b(a){return function(){g[a]=!0,h[a]=d.call(arguments),e()}}function e(){f()&&(j.apply(j,h),a())}function f(){for(var a=0;i>a;a++)if(!g[a])return!1;return!0}var g,h,i=arguments.length,j=c();j.hasListener=function(a){for(var b,c=0;ck;k++)arguments[k].listen(b(k),null);return j}},{"./createAction":8}],7:[function(a,b){var c=a("../src"),d=a("./utils");b.exports=function(a,b){return{componentDidMount:function(){for(var e in c.ListenerMethods)if(this[e]!==c.ListenerMethods[e]){if(this[e])throw"Can't have other property '"+e+"' when using Reflux.listenTo!";this[e]=c.ListenerMethods[e]}var f=this,g=b?function(a){f.setState(d.object([b],[a]))}:this.setState;this.listenTo(a,g,g)},componentWillUnmount:c.ListenerMixin.componentWillUnmount}}},{"../src":10,"./utils":13}],8:[function(a,b){var c=a("./utils"),d=a("../src"),e=a("./Keep");b.exports=function(a){a=a||{};var b=c.extend({eventLabel:"action",emitter:new c.EventEmitter},a,d.PublisherMethods,{preEmit:a.preEmit||d.PublisherMethods.preEmit,shouldEmit:a.shouldEmit||d.PublisherMethods.shouldEmit}),f=function(){b.triggerAsync.apply(b,arguments)};return c.extend(f,b),e.createdActions.push(f),f}},{"../src":10,"./Keep":2,"./utils":13}],9:[function(a,b){var c=a("./utils"),d=a("../src"),e=a("./Keep");b.exports=function(a){function b(){var a,b=0;if(this.subscriptions=[],this.emitter=new c.EventEmitter,this.eventLabel="change",this.init&&c.isFunction(this.init)&&this.init(),this.listenables)for(a=[].concat(this.listenables);be;e++){b=arguments[e];for(c in b)a[c]=b[c]}return a},c.isFunction=function(a){return"function"==typeof a},c.EventEmitter=a("eventemitter3"),c.nextTick=function(a){setTimeout(a,0)},c.callbackName=function(a){return"on"+a.charAt(0).toUpperCase()+a.slice(1)},c.object=function(a,b){for(var c={},d=0;d