hippodrome 0.2.2 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06d409b2b94cb4a499662efdd6cc288cc49c35ab
4
- data.tar.gz: 59bbd7e6a3c85baa83a9b095a175c51134d60bb6
3
+ metadata.gz: 8ab489f9b943d93a9458f0ded0ade68993db1245
4
+ data.tar.gz: 7f53f29718feedd55171a0080d2a78ed023ed059
5
5
  SHA512:
6
- metadata.gz: 3a9dc2b7b828dfe02f37b9f44434b61007b1ca39c09656183a29d48c3851b5cf6eadf8b3b63e42117ef54472c657beb2b26dda4bd877d127050729d33b378a73
7
- data.tar.gz: 62ff67cc87ad315f9e686c3978d3785225c1ab396eab29f84ceee5a41eeec5d45599492616f409e78551a0c3b115379a4635661f0d7639aa8c44d365614a6ebe
6
+ metadata.gz: 9b76419c0416a07b95ac5c0013dac9c57c8a2632ee31c50dab35d59a05dda9948ce20e65b7cf0f9478e327f2589d3d2532d26363de8a57c3f2c11f8860060593
7
+ data.tar.gz: dd3a24eb141580c4c54a279292e3be804d2b33f770b5638f5cf3bd811ba124b77929219809c118591e27a68c1f5fac571d0005ca895e31bb27f9f8df3c3d0a2e
@@ -227,8 +227,14 @@
227
227
  dispatcherIdsByAction: {},
228
228
  callbacks: [],
229
229
  trigger: function() {
230
- return _.each(this.callbacks, function(callback) {
231
- return callback();
230
+ return _.each(this.callbacks, function(spec) {
231
+ var callback, context;
232
+ callback = spec.callback, context = spec.context;
233
+ if (context) {
234
+ return callback.call(context);
235
+ } else {
236
+ return callback();
237
+ }
232
238
  });
233
239
  },
234
240
  dispatch: function(action) {
@@ -251,11 +257,19 @@
251
257
  store = {
252
258
  _storeImpl: storeImpl,
253
259
  displayName: options.displayName,
254
- register: function(callback) {
255
- return this._storeImpl.callbacks.push(callback);
260
+ register: function(callback, context) {
261
+ if (context == null) {
262
+ context = null;
263
+ }
264
+ return this._storeImpl.callbacks.push({
265
+ callback: callback,
266
+ context: context
267
+ });
256
268
  },
257
269
  unregister: function(callback) {
258
- return _.remove(this._storeImpl.callbacks, function(cb) {
270
+ return _.remove(this._storeImpl.callbacks, function(spec) {
271
+ var cb;
272
+ cb = spec.callback;
259
273
  return cb === callback;
260
274
  });
261
275
  },
@@ -273,14 +287,13 @@
273
287
  };
274
288
  return {
275
289
  componentWillMount: function() {
276
- callback = callback.bind(this);
277
- return callback();
290
+ return callback.call(this);
278
291
  },
279
292
  componentDidMount: function() {
280
- return store.register(callback);
293
+ return store.register(callback, this);
281
294
  },
282
295
  componentWillUnmount: function() {
283
- return store.unregister(callback);
296
+ return store.unregister(callback, this);
284
297
  }
285
298
  };
286
299
  },
@@ -292,14 +305,13 @@
292
305
  };
293
306
  return {
294
307
  componentWillMount: function() {
295
- callback = callback.bind(this);
296
- return callback();
308
+ return callback.call(this);
297
309
  },
298
310
  componentDidMount: function() {
299
- return store.register(callback);
311
+ return store.register(callback, this);
300
312
  },
301
313
  componentWillUnmount: function() {
302
- return store.unregister(callback);
314
+ return store.unregister(callback, this);
303
315
  }
304
316
  };
305
317
  }
@@ -1,3 +1,3 @@
1
1
  //= require lodash
2
2
 
3
- (function(){var t,i,n,e,r,a,s,c,o,u,l,d,p,h,f=[].slice;l="undefined"==typeof window,h=l?require("lodash"):this._,t={},e=function(){var t,i,n,e,r;if(n=arguments[0],r=arguments[1],i=3<=arguments.length?f.call(arguments,2):[],!n)throw t=0,e=new Error("Assertion Failed: "+r.replace(/%s/g,function(){return i[t++]})),e.framesToPop=1,e;return n},i=function(t){return this._lastId=1,this._prefix=t},i.prototype.next=function(){return""+this._prefix+"_"+this._lastId++},n=new i("Action_ID"),a=function(i){var r,a,s;return e(i.build instanceof Function,"Action "+i.displayName+" did not define a build function."),s=""+n.next()+"_"+i.displayName,a=function(){var t;return t=i.build.apply(null,arguments),t._action=s,t},r=function(){var i;return i=a.apply(null,arguments),t.Dispatcher.dispatch(i)},r.buildPayload=a,r.displayName=i.displayName,r.id=s,r.toString=function(){return s},r},t.createAction=a,u=new i("Dispatcher_ID"),c=function(){var t;return t={_callbacksByAction:{},_isStarted:{},_isFinished:{},_isDispatching:!1,_payload:null},t.register=function(t,i,n){var e,r;return null==n&&(n=[]),null==(r=this._callbacksByAction)[t]&&(r[t]={}),e=u.next(),this._callbacksByAction[t][e]={callback:i,prerequisites:n},e},t.unregister=function(t,i){return e(this._callbacksByAction&&this._callbacksByAction[t][i],"Dispatcher.unregister("+t.displayName+", "+i+") does not map to a registered callback."),delete this._callbacksByAction[t][i]},t.waitFor=function(t,i){return e(this._isDispatching,"Dispatcher.waitFor must be called while dispatching."),h.forEach(i,function(i){return function(n){var r;return r=n._storeImpl.dispatcherIdsByAction[t],i._isStarted[r]?void e(i._isFinished[r],"Dispatcher.waitFor encountered circular dependency trying to wait for "+r+" during action "+t.displayName+"."):(e(i._callbacksByAction[t][r],"Dispatcher.waitFor "+r+" is not a registered callback for "+t.displayName+"."),i.invokeCallback(t,r))}}(this))},t.dispatch=function(t){var i;e(!this._isDispatching,"Dispatcher.dispatch cannot be called during dispatch."),this.startDispatching(t);try{return i=t._action,h.forEach(this._callbacksByAction[i],function(t){return function(n,e){return t._isStarted[e]?void 0:t.invokeCallback(i,e)}}(this))}finally{this.stopDispatching()}},t.invokeCallback=function(t,i){var n,e,r;return this._isStarted[i]=!0,r=this._callbacksByAction[t][i],n=r.callback,e=r.prerequisites,this.waitFor(t,e),n(this._payload),this._isFinished[i]=!0},t.startDispatching=function(t){return this._isStarted={},this._isFinished={},this._payload=t,this._isDispatching=!0},t.stopDispatching=function(){return this._payload=null,this._isDispatching=!1},t},t.Dispatcher=c(),d=function(t,i){return"string"==typeof i&&(i=t[i]),function(){var n;return n=arguments,setTimeout(function(){return i.apply(t,n)},1)}},s=function(i){var n;return e(!i.action||i.task,"Deferred Task "+i.displayName+" declared an action, it must declare a task."),e(!i.task||i.action,"Deferred Task "+i.displayName+" declared a task, it must declare an action."),n={},h.assign(n,h.omit(i,"initialize","action","task"),r(n)),n.dispatch=function(i){var r;return e(void 0===n._dispatcherIdsByAction[i.id],"Deferred Task "+n.displayName+" attempted to register twice for action "+i.displayName+"."),r=function(e){var r;return e=d(n,e),r=t.Dispatcher.register(i.id,e),n._dispatcherIdsByAction[i.id]=r,r},{to:r}},n._dispatcherIdsByAction={},i.initialize&&n.dispatch(t.start).to(i.initialize),i.action&&i.task&&n.dispatch(i.action).to(i.task),n},t.createDeferredTask=s,r=function(t){return function(i,n){return n instanceof Function?n.bind(t):n}},p=function(i,n,e){return null==e&&(e=[]),function(r){var a;return"string"==typeof r&&(r=i[r]),r=r.bind(i),a=t.Dispatcher.register(n.id,r,e),i.dispatcherIdsByAction[n]=a}},o=function(i){var n,a;return a={dispatcherIdsByAction:{},callbacks:[],trigger:function(){return h.each(this.callbacks,function(t){return t()})},dispatch:function(t){var i,n;return e(void 0===this.dispatcherIdsByAction[t],"Store "+this.displayName+" attempted to register twice for action "+t.displayName+"."),n=this,i=function(){var i;return i=arguments,{to:p(n,t,i)}},{after:i,to:p(n,t)}}},n={_storeImpl:a,displayName:i.displayName,register:function(t){return this._storeImpl.callbacks.push(t)},unregister:function(t){return h.remove(this._storeImpl.callbacks,function(i){return i===t})},listen:function(t,i){var e,r;return n=this,r=function(){var n;return n={},n[t]=i(),n},e=function(){return this.setState(r())},{componentWillMount:function(){return(e=e.bind(this))()},componentDidMount:function(){return n.register(e)},componentWillUnmount:function(){return n.unregister(e)}}},listenWith:function(t){var i;return n=this,i=function(){return this.setState(this[t]())},{componentWillMount:function(){return(i=i.bind(this))()},componentDidMount:function(){return n.register(i)},componentWillUnmount:function(){return n.unregister(i)}}}},h.assign(a,h.omit(i,"initialize","public"),r(a)),i["public"]&&(h.assign(n,i["public"],r(a)),h.assign(a,i["public"],r(a))),i.initialize&&a.dispatch(t.start).to(i.initialize),n},t.createStore=o,t.start=new t.createAction({displayName:"start Hippodrome",build:function(t){return t||{}}}),l?module.exports=t:this.Hippodrome=t}).call(this);
3
+ (function(){var t,i,n,e,r,a,s,c,o,u,l,d,p,h,f=[].slice;l="undefined"==typeof window,h=l?require("lodash"):this._,t={},e=function(){var t,i,n,e,r;if(n=arguments[0],r=arguments[1],i=3<=arguments.length?f.call(arguments,2):[],!n)throw t=0,e=new Error("Assertion Failed: "+r.replace(/%s/g,function(){return i[t++]})),e.framesToPop=1,e;return n},i=function(t){return this._lastId=1,this._prefix=t},i.prototype.next=function(){return""+this._prefix+"_"+this._lastId++},n=new i("Action_ID"),a=function(i){var r,a,s;return e(i.build instanceof Function,"Action "+i.displayName+" did not define a build function."),s=""+n.next()+"_"+i.displayName,a=function(){var t;return t=i.build.apply(null,arguments),t._action=s,t},r=function(){var i;return i=a.apply(null,arguments),t.Dispatcher.dispatch(i)},r.buildPayload=a,r.displayName=i.displayName,r.id=s,r.toString=function(){return s},r},t.createAction=a,u=new i("Dispatcher_ID"),c=function(){var t;return t={_callbacksByAction:{},_isStarted:{},_isFinished:{},_isDispatching:!1,_payload:null},t.register=function(t,i,n){var e,r;return null==n&&(n=[]),null==(r=this._callbacksByAction)[t]&&(r[t]={}),e=u.next(),this._callbacksByAction[t][e]={callback:i,prerequisites:n},e},t.unregister=function(t,i){return e(this._callbacksByAction&&this._callbacksByAction[t][i],"Dispatcher.unregister("+t.displayName+", "+i+") does not map to a registered callback."),delete this._callbacksByAction[t][i]},t.waitFor=function(t,i){return e(this._isDispatching,"Dispatcher.waitFor must be called while dispatching."),h.forEach(i,function(i){return function(n){var r;return r=n._storeImpl.dispatcherIdsByAction[t],i._isStarted[r]?void e(i._isFinished[r],"Dispatcher.waitFor encountered circular dependency trying to wait for "+r+" during action "+t.displayName+"."):(e(i._callbacksByAction[t][r],"Dispatcher.waitFor "+r+" is not a registered callback for "+t.displayName+"."),i.invokeCallback(t,r))}}(this))},t.dispatch=function(t){var i;e(!this._isDispatching,"Dispatcher.dispatch cannot be called during dispatch."),this.startDispatching(t);try{return i=t._action,h.forEach(this._callbacksByAction[i],function(t){return function(n,e){return t._isStarted[e]?void 0:t.invokeCallback(i,e)}}(this))}finally{this.stopDispatching()}},t.invokeCallback=function(t,i){var n,e,r;return this._isStarted[i]=!0,r=this._callbacksByAction[t][i],n=r.callback,e=r.prerequisites,this.waitFor(t,e),n(this._payload),this._isFinished[i]=!0},t.startDispatching=function(t){return this._isStarted={},this._isFinished={},this._payload=t,this._isDispatching=!0},t.stopDispatching=function(){return this._payload=null,this._isDispatching=!1},t},t.Dispatcher=c(),d=function(t,i){return"string"==typeof i&&(i=t[i]),function(){var n;return n=arguments,setTimeout(function(){return i.apply(t,n)},1)}},s=function(i){var n;return e(!i.action||i.task,"Deferred Task "+i.displayName+" declared an action, it must declare a task."),e(!i.task||i.action,"Deferred Task "+i.displayName+" declared a task, it must declare an action."),n={},h.assign(n,h.omit(i,"initialize","action","task"),r(n)),n.dispatch=function(i){var r;return e(void 0===n._dispatcherIdsByAction[i.id],"Deferred Task "+n.displayName+" attempted to register twice for action "+i.displayName+"."),r=function(e){var r;return e=d(n,e),r=t.Dispatcher.register(i.id,e),n._dispatcherIdsByAction[i.id]=r,r},{to:r}},n._dispatcherIdsByAction={},i.initialize&&n.dispatch(t.start).to(i.initialize),i.action&&i.task&&n.dispatch(i.action).to(i.task),n},t.createDeferredTask=s,r=function(t){return function(i,n){return n instanceof Function?n.bind(t):n}},p=function(i,n,e){return null==e&&(e=[]),function(r){var a;return"string"==typeof r&&(r=i[r]),r=r.bind(i),a=t.Dispatcher.register(n.id,r,e),i.dispatcherIdsByAction[n]=a}},o=function(i){var n,a;return a={dispatcherIdsByAction:{},callbacks:[],trigger:function(){return h.each(this.callbacks,function(t){var i,n;return i=t.callback,n=t.context,n?i.call(n):i()})},dispatch:function(t){var i,n;return e(void 0===this.dispatcherIdsByAction[t],"Store "+this.displayName+" attempted to register twice for action "+t.displayName+"."),n=this,i=function(){var i;return i=arguments,{to:p(n,t,i)}},{after:i,to:p(n,t)}}},n={_storeImpl:a,displayName:i.displayName,register:function(t,i){return null==i&&(i=null),this._storeImpl.callbacks.push({callback:t,context:i})},unregister:function(t){return h.remove(this._storeImpl.callbacks,function(i){var n;return n=i.callback,n===t})},listen:function(t,i){var e,r;return n=this,r=function(){var n;return n={},n[t]=i(),n},e=function(){return this.setState(r())},{componentWillMount:function(){return e.call(this)},componentDidMount:function(){return n.register(e,this)},componentWillUnmount:function(){return n.unregister(e,this)}}},listenWith:function(t){var i;return n=this,i=function(){return this.setState(this[t]())},{componentWillMount:function(){return i.call(this)},componentDidMount:function(){return n.register(i,this)},componentWillUnmount:function(){return n.unregister(i,this)}}}},h.assign(a,h.omit(i,"initialize","public"),r(a)),i["public"]&&(h.assign(n,i["public"],r(a)),h.assign(a,i["public"],r(a))),i.initialize&&a.dispatch(t.start).to(i.initialize),n},t.createStore=o,t.start=new t.createAction({displayName:"start Hippodrome",build:function(t){return t||{}}}),l?module.exports=t:this.Hippodrome=t}).call(this);
@@ -1,3 +1,3 @@
1
1
  module Hippodrome
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.9'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hippodrome
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Kermes
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-01-14 00:00:00.000000000 Z
12
+ date: 2015-01-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler