hippodrome 0.1.8 → 0.2.0

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: 3bb092221b5b0a477d3bedcdaf4fbc532ecc5c91
4
- data.tar.gz: e6387d77205f198dca6de17cc44ec849fdf180c4
3
+ metadata.gz: cea5a30796c2f07b1c942ab9bd1b42c711b1e416
4
+ data.tar.gz: 8d3ed9d54d4c10099538105eb9b47b2e472519f2
5
5
  SHA512:
6
- metadata.gz: 8811d6d654b9b49a2ad3d5ff346d2c27dfb9b72bac4e3859b405448d41edfc84091eebea41b6194af5d0cd82773a3643b316d69fb03ce73e3af75ee3de9a77f1
7
- data.tar.gz: 01136d11b4d14c2b4a6d15be520b8d730041e904b83db20386a7c96325ff4cccd845885c0e059eee29841cfe7b683b99af619ffa69a6f471047e009c66820461
6
+ metadata.gz: 3953db98cf94e79fcce5f6c781e01ae28e40f2eb2830705f59849fe06b19bb1793df1e00f15a9062e588f5c298e1f2f9590a8954fd5ba44a3837fadf864e9dc9
7
+ data.tar.gz: a5b7b1d345ada7db75e5751751931d83108518e8fea95b85f2ecc2e4f39bcca04e212b01ac8d6ea5845f4fc36ce0ced98e7e56b67b7f0ba16374e543e9a22891
@@ -1,7 +1,7 @@
1
1
  //= require lodash
2
2
 
3
3
  (function() {
4
- var Action, DeferredTask, Dispatcher, Hippodrome, IdFactory, Store, actionIds, assert, bindToContextIfFunction, dispatcherIds, isNode, makeDeferredFunction, _,
4
+ var Hippodrome, IdFactory, actionIds, assert, bindToContextIfFunction, createAction, createDeferredTask, createDispatcher, createStore, dispatcherIds, isNode, makeDeferredFunction, makeToFn, _,
5
5
  __slice = [].slice;
6
6
 
7
7
  isNode = typeof window === 'undefined';
@@ -39,126 +39,117 @@
39
39
 
40
40
  actionIds = new IdFactory('Action_ID');
41
41
 
42
- Action = function(name, ctor) {
43
- var actionFn, buildPayload, id, send;
44
- id = "" + (actionIds.next()) + "_" + name;
42
+ createAction = function(options) {
43
+ var action, buildPayload, id;
44
+ assert(options.build instanceof Function, "Action " + options.displayName + " did not define a build function.");
45
+ id = "" + (actionIds.next()) + "_" + options.displayName;
45
46
  buildPayload = function() {
46
47
  var payload;
47
- payload = ctor.apply(null, arguments);
48
- payload.action = id;
48
+ payload = options.build.apply(null, arguments);
49
+ payload._action = id;
49
50
  return payload;
50
51
  };
51
- send = function(payload) {
52
- return Hippodrome.Dispatcher.dispatch(payload);
53
- };
54
- actionFn = function() {
52
+ action = function() {
55
53
  var payload;
56
54
  payload = buildPayload.apply(null, arguments);
57
- return send(payload);
55
+ return Hippodrome.Dispatcher.dispatch(payload);
58
56
  };
59
- actionFn.buildPayload = buildPayload;
60
- actionFn.send = send;
61
- actionFn.displayName = name;
62
- actionFn.id = id;
63
- actionFn.toString = function() {
57
+ action.buildPayload = buildPayload;
58
+ action.displayName = options.displayName;
59
+ action.id = id;
60
+ action.toString = function() {
64
61
  return id;
65
62
  };
66
- return actionFn;
63
+ return action;
67
64
  };
68
65
 
69
- Hippodrome.Action = Action;
70
-
71
- Dispatcher = function() {
72
- this._callbacksByAction = {};
73
- this._isStarted = {};
74
- this._isFinished = {};
75
- this._isDispatching = false;
76
- return this._payload = null;
77
- };
66
+ Hippodrome.createAction = createAction;
78
67
 
79
68
  dispatcherIds = new IdFactory('Dispatcher_ID');
80
69
 
81
- Dispatcher.prototype.register = function() {
82
- var action, args, callback, id, prereqStores, store, _base;
83
- args = _.compact(arguments);
84
- if (args.length === 3) {
85
- return this.register(args[0], args[1], [], args[2]);
86
- } else {
87
- store = args[0], action = args[1], prereqStores = args[2], callback = args[3];
70
+ createDispatcher = function() {
71
+ var dispatcher;
72
+ dispatcher = {
73
+ _callbacksByAction: {},
74
+ _isStarted: {},
75
+ _isFinished: {},
76
+ _isDispatching: false,
77
+ _payload: null
78
+ };
79
+ dispatcher.register = function(action, callback, prerequisites) {
80
+ var id, _base;
81
+ if (prerequisites == null) {
82
+ prerequisites = [];
83
+ }
88
84
  if ((_base = this._callbacksByAction)[action] == null) {
89
85
  _base[action] = {};
90
86
  }
91
87
  id = dispatcherIds.next();
92
88
  this._callbacksByAction[action][id] = {
93
89
  callback: callback,
94
- prerequisites: _.map(prereqStores, function(ps) {
95
- return ps._storeImpl.dispatcherIdsByAction[action];
96
- })
90
+ prerequisites: prerequisites
97
91
  };
98
92
  return id;
99
- }
100
- };
101
-
102
- Dispatcher.prototype.unregister = function(action, id) {
103
- assert(this._callbacksByAction[action][id], 'Dispatcher.unregister(%s, %s) does not map to a registered callback.', action.displayName, id);
104
- return this._callbacksByAction[action][id] = null;
105
- };
106
-
107
- Dispatcher.prototype.waitFor = function(action, ids) {
108
- assert(this._isDispatching, 'Dispatcher.waitFor must be invoked while dispatching.');
109
- return _.forEach(ids, (function(_this) {
110
- return function(id) {
111
- if (_this._isStarted[id]) {
112
- assert(_this._isFinished[id], 'Dispatcher.waitFor encountered circular dependency while ' + 'waiting for `%s` during %s.', id, action.displayName);
113
- return;
114
- }
115
- assert(_this._callbacksByAction[action][id], 'Dispatcher.waitFor `%s` is not a registered callback for %s.', id, action.displayName);
116
- return _this.invokeCallback(action, id);
117
- };
118
- })(this));
119
- };
120
-
121
- Dispatcher.prototype.dispatch = function(payload) {
122
- var action;
123
- assert(!this._isDispatching, 'Dispatch.dispatch cannot be called during dispatch.');
124
- this.startDispatching(payload);
125
- try {
126
- action = payload.action;
127
- return _.forEach(this._callbacksByAction[action], (function(_this) {
128
- return function(callback, id) {
93
+ };
94
+ dispatcher.unregister = function(action, id) {
95
+ assert(this._callbacksByAction && this._callbacksByAction[action][id], "Dispatcher.unregister(" + action.displayName + ", " + id + ") does not map to a registered callback.");
96
+ return delete this._callbacksByAction[action][id];
97
+ };
98
+ dispatcher.waitFor = function(action, stores) {
99
+ assert(this._isDispatching, "Dispatcher.waitFor must be called while dispatching.");
100
+ return _.forEach(stores, (function(_this) {
101
+ return function(store) {
102
+ var id;
103
+ id = store._storeImpl.dispatcherIdsByAction[action];
129
104
  if (_this._isStarted[id]) {
105
+ assert(_this._isFinished[id], "Dispatcher.waitFor encountered circular dependency trying to wait for " + id + " during action " + action.displayName + ".");
130
106
  return;
131
107
  }
108
+ assert(_this._callbacksByAction[action][id], "Dispatcher.waitFor " + id + " is not a registered callback for " + action.displayName + ".");
132
109
  return _this.invokeCallback(action, id);
133
110
  };
134
111
  })(this));
135
- } finally {
136
- this.stopDispatching();
137
- }
138
- };
139
-
140
- Dispatcher.prototype.invokeCallback = function(action, id) {
141
- var callback, prerequisites, _ref;
142
- this._isStarted[id] = true;
143
- _ref = this._callbacksByAction[action][id], callback = _ref.callback, prerequisites = _ref.prerequisites;
144
- this.waitFor(action, prerequisites);
145
- callback(this._payload);
146
- return this._isFinished[id] = true;
147
- };
148
-
149
- Dispatcher.prototype.startDispatching = function(payload) {
150
- this._isStarted = {};
151
- this._isFinished = {};
152
- this._payload = payload;
153
- return this._isDispatching = true;
154
- };
155
-
156
- Dispatcher.prototype.stopDispatching = function() {
157
- this._payload = null;
158
- return this._isDispatching = false;
112
+ };
113
+ dispatcher.dispatch = function(payload) {
114
+ var action;
115
+ assert(!this._isDispatching, "Dispatcher.dispatch cannot be called during dispatch.");
116
+ this.startDispatching(payload);
117
+ try {
118
+ action = payload._action;
119
+ return _.forEach(this._callbacksByAction[action], (function(_this) {
120
+ return function(callback, id) {
121
+ if (_this._isStarted[id]) {
122
+ return;
123
+ }
124
+ return _this.invokeCallback(action, id);
125
+ };
126
+ })(this));
127
+ } finally {
128
+ this.stopDispatching();
129
+ }
130
+ };
131
+ dispatcher.invokeCallback = function(action, id) {
132
+ var callback, prerequisites, _ref;
133
+ this._isStarted[id] = true;
134
+ _ref = this._callbacksByAction[action][id], callback = _ref.callback, prerequisites = _ref.prerequisites;
135
+ this.waitFor(action, prerequisites);
136
+ callback(this._payload);
137
+ return this._isFinished[id] = true;
138
+ };
139
+ dispatcher.startDispatching = function(payload) {
140
+ this._isStarted = {};
141
+ this._isFinished = {};
142
+ this._payload = payload;
143
+ return this._isDispatching = true;
144
+ };
145
+ dispatcher.stopDispatching = function() {
146
+ this._payload = null;
147
+ return this._isDispatching = false;
148
+ };
149
+ return dispatcher;
159
150
  };
160
151
 
161
- Hippodrome.Dispatcher = new Dispatcher();
152
+ Hippodrome.Dispatcher = createDispatcher();
162
153
 
163
154
  makeDeferredFunction = function(context, fn) {
164
155
  if (typeof fn === 'string') {
@@ -173,38 +164,37 @@
173
164
  };
174
165
  };
175
166
 
176
- DeferredTask = function(options) {
177
- var action, id, task;
178
- this.displayName = options.displayName;
179
- assert(options.action || options.dispatches, "Deferred Task " + this.displayName + " must include either an action key or dispatches list.");
180
- assert(!options.action || options.task, "Deferred Task " + this.displayName + " declared an action, it must declare a task.");
181
- _.assign(this, _.omit(options, 'dispatches', 'action', 'task'), bindToContextIfFunction(this));
182
- this._dispatcherIdsByAction = {};
167
+ createDeferredTask = function(options) {
168
+ var task;
169
+ assert(!options.action || options.task, "Deferred Task " + options.displayName + " declared an action, it must declare a task.");
170
+ assert(!options.task || options.action, "Deferred Task " + options.displayName + " declared a task, it must declare an action.");
171
+ task = {};
172
+ _.assign(task, _.omit(options, 'initialize', 'action', 'task'), bindToContextIfFunction(task));
173
+ task.dispatch = function(action) {
174
+ var to;
175
+ assert(task._dispatcherIdsByAction[action.id] === void 0, "Deferred Task " + task.displayName + " attempted to register twice for action " + action.displayName + ".");
176
+ to = function(callback) {
177
+ var id;
178
+ callback = makeDeferredFunction(task, callback);
179
+ id = Hippodrome.Dispatcher.register(action.id, callback);
180
+ task._dispatcherIdsByAction[action.id] = id;
181
+ return id;
182
+ };
183
+ return {
184
+ to: to
185
+ };
186
+ };
187
+ task._dispatcherIdsByAction = {};
183
188
  if (options.initialize) {
184
- options.initialize.call(this);
189
+ task.dispatch(Hippodrome.start).to(options.initialize);
185
190
  }
186
191
  if (options.action && options.task) {
187
- action = options.action, task = options.task;
188
- task = makeDeferredFunction(this, task);
189
- id = Hippodrome.Dispatcher.register(this, action.id, [], task);
190
- this._dispatcherIdsByAction[action.id] = id;
191
- }
192
- if (options.dispatches) {
193
- _.forEach(options.dispatches, (function(_this) {
194
- return function(dispatch) {
195
- var callback;
196
- action = dispatch.action, callback = dispatch.callback;
197
- assert(!_this._dispatcherIdsByAction[action.id], "Deferred Task " + _this.displayName + " registered two callbacks for the action " + action.displayName + ".");
198
- callback = makeDeferredFunction(_this, callback);
199
- id = Hippodrome.Dispatcher.register(_this, action.id, [], callback);
200
- return _this._dispatcherIdsByAction[action.id] = id;
201
- };
202
- })(this));
192
+ task.dispatch(options.action).to(options.task);
203
193
  }
204
- return this;
194
+ return task;
205
195
  };
206
196
 
207
- Hippodrome.DeferredTask = DeferredTask;
197
+ Hippodrome.createDeferredTask = createDeferredTask;
208
198
 
209
199
  bindToContextIfFunction = function(context) {
210
200
  return function(objValue, srcValue) {
@@ -216,80 +206,123 @@
216
206
  };
217
207
  };
218
208
 
219
- Store = function(options) {
220
- this._storeImpl = {
209
+ makeToFn = function(context, action, prerequisites) {
210
+ if (prerequisites == null) {
211
+ prerequisites = [];
212
+ }
213
+ return function(callback) {
214
+ var id;
215
+ if (typeof callback === 'string') {
216
+ callback = context[callback];
217
+ }
218
+ callback = callback.bind(context);
219
+ id = Hippodrome.Dispatcher.register(action.id, callback, prerequisites);
220
+ return context.dispatcherIdsByAction[action] = id;
221
+ };
222
+ };
223
+
224
+ createStore = function(options) {
225
+ var store, storeImpl;
226
+ storeImpl = {
227
+ dispatcherIdsByAction: {},
228
+ callbacks: [],
221
229
  trigger: function() {
222
230
  return _.each(this.callbacks, function(callback) {
223
231
  return callback();
224
232
  });
233
+ },
234
+ dispatch: function(action) {
235
+ var after, context;
236
+ assert(this.dispatcherIdsByAction[action] === void 0, "Store " + this.displayName + " attempted to register twice for action " + action.displayName + ".");
237
+ context = this;
238
+ after = function() {
239
+ var prerequisites;
240
+ prerequisites = arguments;
241
+ return {
242
+ to: makeToFn(context, action, prerequisites)
243
+ };
244
+ };
245
+ return {
246
+ after: after,
247
+ to: makeToFn(context, action)
248
+ };
225
249
  }
226
250
  };
227
- this._storeImpl.dispatcherIdsByAction = {};
228
- this._storeImpl.callbacks = [];
229
- _.assign(this._storeImpl, _.omit(options, 'initialize', 'dispatches', 'public'), bindToContextIfFunction(this._storeImpl));
230
- if (options["public"]) {
231
- _.assign(this, options["public"], bindToContextIfFunction(this._storeImpl));
232
- _.assign(this._storeImpl, options["public"], bindToContextIfFunction(this._storeImpl));
233
- }
234
- this.displayName = options.displayName;
235
- this.lastActionId = (function(_this) {
236
- return function() {
237
- return _this._storeImpl._lastActionId;
238
- };
239
- })(this);
240
- if (options.initialize) {
241
- options.initialize.call(this._storeImpl);
242
- }
243
- if (options.dispatches) {
244
- _.forEach(options.dispatches, (function(_this) {
245
- return function(dispatch) {
246
- var action, after, callback, handleAction, id;
247
- action = dispatch.action, after = dispatch.after, callback = dispatch.callback;
248
- assert(!_this._storeImpl.dispatcherIdsByAction[action.id], "Store " + _this.displayName + " registered two callbacks for action " + action.displayName);
249
- if (typeof callback === 'string') {
250
- callback = _this._storeImpl[callback];
251
+ store = {
252
+ _storeImpl: storeImpl,
253
+ displayName: options.displayName,
254
+ register: function(callback) {
255
+ return this._storeImpl.callbacks.push(callback);
256
+ },
257
+ unregister: function(callback) {
258
+ return _.remove(this._storeImpl.callbacks, function(cb) {
259
+ return cb === callback;
260
+ });
261
+ },
262
+ listen: function(property, fn) {
263
+ var callback, getState;
264
+ store = this;
265
+ getState = function() {
266
+ var state;
267
+ state = {};
268
+ state[property] = fn();
269
+ return state;
270
+ };
271
+ callback = function() {
272
+ return this.setState(getState());
273
+ };
274
+ return {
275
+ getInitialState: function() {
276
+ return getState();
277
+ },
278
+ componentDidMount: function() {
279
+ callback = callback.bind(this);
280
+ return store.register(callback);
281
+ },
282
+ componentWillUnmount: function() {
283
+ return store.unregister(callback);
251
284
  }
252
- callback = callback.bind(_this._storeImpl);
253
- handleAction = (function(payload) {
254
- this._lastActionId = payload.action;
255
- return callback(payload);
256
- }).bind(_this._storeImpl);
257
- id = Hippodrome.Dispatcher.register(_this, action.id, after, handleAction);
258
- return _this._storeImpl.dispatcherIdsByAction[action.id] = id;
259
285
  };
260
- })(this));
261
- }
262
- return this;
263
- };
264
-
265
- Store.prototype.register = function(callback) {
266
- return this._storeImpl.callbacks.push(callback);
267
- };
268
-
269
- Store.prototype.unregister = function(callback) {
270
- return this._storeImpl.callbacks = _.reject(this._storeImpl.callbacks, function(cb) {
271
- return cb === callback;
272
- });
273
- };
274
-
275
- Store.prototype.listen = function(callbackName) {
276
- var store;
277
- store = this;
278
- return {
279
- componentDidMount: function() {
280
- return store.register(this[callbackName]);
281
286
  },
282
- componentWillUnmount: function() {
283
- return store.unregister(this[callbackName]);
287
+ listenWith: function(stateFnName) {
288
+ var callback;
289
+ store = this;
290
+ callback = function() {
291
+ return this.setState(this[stateFnName]());
292
+ };
293
+ return {
294
+ getInitialState: function() {
295
+ return this[stateFnName]();
296
+ },
297
+ componentDidMount: function() {
298
+ callback = callback.bind(this);
299
+ return store.register(callback);
300
+ },
301
+ componentWillUnmount: function() {
302
+ return store.unregister(callback);
303
+ }
304
+ };
284
305
  }
285
306
  };
307
+ _.assign(storeImpl, _.omit(options, 'initialize', 'public'), bindToContextIfFunction(storeImpl));
308
+ if (options["public"]) {
309
+ _.assign(store, options["public"], bindToContextIfFunction(storeImpl));
310
+ _.assign(storeImpl, options["public"], bindToContextIfFunction(storeImpl));
311
+ }
312
+ if (options.initialize) {
313
+ storeImpl.dispatch(Hippodrome.start).to(options.initialize);
314
+ }
315
+ return store;
286
316
  };
287
317
 
288
- Store.prototype.trigger = function() {
289
- return this._storeImpl.trigger();
290
- };
318
+ Hippodrome.createStore = createStore;
291
319
 
292
- Hippodrome.Store = Store;
320
+ Hippodrome.start = new Hippodrome.createAction({
321
+ displayName: 'start Hippodrome',
322
+ build: function(options) {
323
+ return options || {};
324
+ }
325
+ });
293
326
 
294
327
  if (isNode) {
295
328
  module.exports = Hippodrome;
@@ -1,3 +1,3 @@
1
1
  //= require lodash
2
2
 
3
- (function(){var t,i,s,n,e,r,a,c,o,l,p,u,h,d=[].slice;p="undefined"==typeof window,h=p?require("lodash"):this._,n={},c=function(){var t,i,s,n,e;if(s=arguments[0],e=arguments[1],i=3<=arguments.length?d.call(arguments,2):[],!s)throw t=0,n=new Error("Assertion Failed: "+e.replace(/%s/g,function(){return i[t++]})),n.framesToPop=1,n;return s},e=function(t){return this._lastId=1,this._prefix=t},e.prototype.next=function(){return""+this._prefix+"_"+this._lastId++},a=new e("Action_ID"),t=function(t,i){var s,e,r,c;return r=""+a.next()+"_"+t,e=function(){var t;return t=i.apply(null,arguments),t.action=r,t},c=function(t){return n.Dispatcher.dispatch(t)},s=function(){var t;return t=e.apply(null,arguments),c(t)},s.buildPayload=e,s.send=c,s.displayName=t,s.id=r,s.toString=function(){return r},s},n.Action=t,s=function(){return this._callbacksByAction={},this._isStarted={},this._isFinished={},this._isDispatching=!1,this._payload=null},l=new e("Dispatcher_ID"),s.prototype.register=function(){var t,i,s,n,e,r,a;return i=h.compact(arguments),3===i.length?this.register(i[0],i[1],[],i[2]):(r=i[0],t=i[1],e=i[2],s=i[3],null==(a=this._callbacksByAction)[t]&&(a[t]={}),n=l.next(),this._callbacksByAction[t][n]={callback:s,prerequisites:h.map(e,function(i){return i._storeImpl.dispatcherIdsByAction[t]})},n)},s.prototype.unregister=function(t,i){return c(this._callbacksByAction[t][i],"Dispatcher.unregister(%s, %s) does not map to a registered callback.",t.displayName,i),this._callbacksByAction[t][i]=null},s.prototype.waitFor=function(t,i){return c(this._isDispatching,"Dispatcher.waitFor must be invoked while dispatching."),h.forEach(i,function(i){return function(s){return i._isStarted[s]?void c(i._isFinished[s],"Dispatcher.waitFor encountered circular dependency while waiting for `%s` during %s.",s,t.displayName):(c(i._callbacksByAction[t][s],"Dispatcher.waitFor `%s` is not a registered callback for %s.",s,t.displayName),i.invokeCallback(t,s))}}(this))},s.prototype.dispatch=function(t){var i;c(!this._isDispatching,"Dispatch.dispatch cannot be called during dispatch."),this.startDispatching(t);try{return i=t.action,h.forEach(this._callbacksByAction[i],function(t){return function(s,n){return t._isStarted[n]?void 0:t.invokeCallback(i,n)}}(this))}finally{this.stopDispatching()}},s.prototype.invokeCallback=function(t,i){var s,n,e;return this._isStarted[i]=!0,e=this._callbacksByAction[t][i],s=e.callback,n=e.prerequisites,this.waitFor(t,n),s(this._payload),this._isFinished[i]=!0},s.prototype.startDispatching=function(t){return this._isStarted={},this._isFinished={},this._payload=t,this._isDispatching=!0},s.prototype.stopDispatching=function(){return this._payload=null,this._isDispatching=!1},n.Dispatcher=new s,u=function(t,i){return"string"==typeof i&&(i=t[i]),function(){var s;return s=arguments,setTimeout(function(){return i.apply(t,s)},1)}},i=function(t){var i,s,e;return this.displayName=t.displayName,c(t.action||t.dispatches,"Deferred Task "+this.displayName+" must include either an action key or dispatches list."),c(!t.action||t.task,"Deferred Task "+this.displayName+" declared an action, it must declare a task."),h.assign(this,h.omit(t,"dispatches","action","task"),o(this)),this._dispatcherIdsByAction={},t.initialize&&t.initialize.call(this),t.action&&t.task&&(i=t.action,e=t.task,e=u(this,e),s=n.Dispatcher.register(this,i.id,[],e),this._dispatcherIdsByAction[i.id]=s),t.dispatches&&h.forEach(t.dispatches,function(t){return function(e){var r;return i=e.action,r=e.callback,c(!t._dispatcherIdsByAction[i.id],"Deferred Task "+t.displayName+" registered two callbacks for the action "+i.displayName+"."),r=u(t,r),s=n.Dispatcher.register(t,i.id,[],r),t._dispatcherIdsByAction[i.id]=s}}(this)),this},n.DeferredTask=i,o=function(t){return function(i,s){return s instanceof Function?s.bind(t):s}},r=function(t){return this._storeImpl={trigger:function(){return h.each(this.callbacks,function(t){return t()})}},this._storeImpl.dispatcherIdsByAction={},this._storeImpl.callbacks=[],h.assign(this._storeImpl,h.omit(t,"initialize","dispatches","public"),o(this._storeImpl)),t["public"]&&(h.assign(this,t["public"],o(this._storeImpl)),h.assign(this._storeImpl,t["public"],o(this._storeImpl))),this.displayName=t.displayName,this.lastActionId=function(t){return function(){return t._storeImpl._lastActionId}}(this),t.initialize&&t.initialize.call(this._storeImpl),t.dispatches&&h.forEach(t.dispatches,function(t){return function(i){var s,e,r,a,o;return s=i.action,e=i.after,r=i.callback,c(!t._storeImpl.dispatcherIdsByAction[s.id],"Store "+t.displayName+" registered two callbacks for action "+s.displayName),"string"==typeof r&&(r=t._storeImpl[r]),r=r.bind(t._storeImpl),a=function(t){return this._lastActionId=t.action,r(t)}.bind(t._storeImpl),o=n.Dispatcher.register(t,s.id,e,a),t._storeImpl.dispatcherIdsByAction[s.id]=o}}(this)),this},r.prototype.register=function(t){return this._storeImpl.callbacks.push(t)},r.prototype.unregister=function(t){return this._storeImpl.callbacks=h.reject(this._storeImpl.callbacks,function(i){return i===t})},r.prototype.listen=function(t){var i;return i=this,{componentDidMount:function(){return i.register(this[t])},componentWillUnmount:function(){return i.unregister(this[t])}}},r.prototype.trigger=function(){return this._storeImpl.trigger()},n.Store=r,p?module.exports=n:this.Hippodrome=n}).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){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())},{getInitialState:function(){return r()},componentDidMount:function(){return e=e.bind(this),n.register(e)},componentWillUnmount:function(){return n.unregister(e)}}},listenWith:function(t){var i;return n=this,i=function(){return this.setState(this[t]())},{getInitialState:function(){return this[t]()},componentDidMount:function(){return i=i.bind(this),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);
@@ -1,3 +1,3 @@
1
1
  module Hippodrome
2
- VERSION = '0.1.8'
2
+ VERSION = '0.2.0'
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.1.8
4
+ version: 0.2.0
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: 2014-12-14 00:00:00.000000000 Z
12
+ date: 2015-01-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -110,4 +110,3 @@ specification_version: 4
110
110
  summary: Your data, like your chariots, go around and around in one direction in this,
111
111
  a Flux implementation that only Ben Hur could love.
112
112
  test_files: []
113
- has_rdoc: