hippodrome 0.0.16 → 0.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2cade2f33b8f261faf01d57453b3776b6603c2e4
4
- data.tar.gz: ace2d0166e2fa55b203d098c472a4bbfd91c385f
3
+ metadata.gz: 8b5036e5c66a8704fd400c621f9c369e0ed3d4d4
4
+ data.tar.gz: e5c3b2aabd0e7b4adefce19d8c1c8d84032e7393
5
5
  SHA512:
6
- metadata.gz: 49a39346480f430a5ca599a90a2febb65a46ebc7aaac0b4930afdcc4e001b397a088f839a7634d22bd3cd956cdf6fabb304ae4c7d7372d221debf0ebc15379d1
7
- data.tar.gz: 6903cf94ec164280f96eef6e47e9db56c4d9c3a73c320fab61da1c7ad777e8e563da442e74378c8a74354a563a62a4be7101ad692cf2025bf77cc3a0fc7bd74e
6
+ metadata.gz: 45584434b782e936b87a02eaa2666d153a428afc9c578b087770f72055fa3e55635a426e3416eeabf53d5b7cfa3768c03dea8b097d624985e61e6881ee5cbeaf
7
+ data.tar.gz: 38ae906af22d94d0a11311c297cfc051e4ed8b1d39e9bd38834c92a922f0ca40ae52f14e6de49859c45e539ebfedf8fda509ba452ffca6aea2e5658cfff7207d
@@ -1,7 +1,7 @@
1
1
  //= require lodash
2
2
 
3
3
  (function() {
4
- var Action, Dispatcher, Hippodrome, SideEffect, Store, assert, bindToContextIfFunction, isNode, lastId, nextId, prefix, _,
4
+ var Action, DeferredTask, Dispatcher, Hippodrome, Store, assert, bindToContextIfFunction, isNode, lastId, nextId, prefix, _,
5
5
  __slice = [].slice;
6
6
 
7
7
  isNode = typeof window === 'undefined';
@@ -85,7 +85,7 @@
85
85
  this.callbacksByAction[action][id] = {
86
86
  callback: callback,
87
87
  prerequisites: _.map(prereqStores, function(ps) {
88
- return ps.dispatcherIdsByAction[action];
88
+ return ps.storeImpl.dispatcherIdsByAction[action];
89
89
  })
90
90
  };
91
91
  return id;
@@ -153,22 +153,22 @@
153
153
 
154
154
  Hippodrome.Dispatcher = new Dispatcher();
155
155
 
156
- SideEffect = function(options) {
157
- var action, effect, id;
158
- assert(options.action, 'SideEffect must register for exactly one action.');
159
- assert(options.effect, 'SideEffect must supply exactly one effect to run');
160
- action = options.action, effect = options.effect;
161
- if (typeof effect === 'string') {
162
- effect = this[effect];
156
+ DeferredTask = function(options) {
157
+ var action, id, task;
158
+ assert(options.action, 'DeferredTask must register for exactly one action.');
159
+ assert(options.task, 'DeferredTask must supply exactly one task to run');
160
+ action = options.action, task = options.task;
161
+ if (typeof task === 'string') {
162
+ task = this[task];
163
163
  }
164
- effect = _.defer.bind(this, effect);
165
- id = Hippodrome.Dispatcher.register(this, action.hippoName, [], effect);
164
+ task = _.defer.bind(this, task);
165
+ id = Hippodrome.Dispatcher.register(this, action.hippoName, [], task);
166
166
  this.dispatcherIdsByAction = {};
167
167
  this.dispatcherIdsByAction[action.hippoName] = id;
168
168
  return this;
169
169
  };
170
170
 
171
- Hippodrome.SideEffect = SideEffect;
171
+ Hippodrome.DeferredTask = DeferredTask;
172
172
 
173
173
  bindToContextIfFunction = function(context) {
174
174
  return function(objValue, srcValue) {
@@ -181,24 +181,28 @@
181
181
  };
182
182
 
183
183
  Store = function(options) {
184
- this.dispatcherIdsByAction = {};
185
- this.callbacks = [];
186
- _.assign(this, _.omit(options, 'initialize', 'dispatches'), bindToContextIfFunction(this));
184
+ this.storeImpl = {};
185
+ this.storeImpl.dispatcherIdsByAction = {};
186
+ this.storeImpl.callbacks = [];
187
+ _.assign(this.storeImpl, _.omit(options, 'initialize', 'dispatches', 'public'), bindToContextIfFunction(this.storeImpl));
188
+ if (options["public"]) {
189
+ _.assign(this, options["public"], bindToContextIfFunction(this.storeImpl));
190
+ }
187
191
  if (options.initialize) {
188
- options.initialize.call(this);
192
+ options.initialize.call(this.storeImpl);
189
193
  }
190
194
  if (options.dispatches) {
191
195
  _.forEach(options.dispatches, (function(_this) {
192
- return function(callbackDescription) {
196
+ return function(dispatch) {
193
197
  var action, after, callback, id;
194
- action = callbackDescription.action, after = callbackDescription.after, callback = callbackDescription.callback;
195
- assert(!_this.dispatcherIdsByAction[action.hippoName], 'Each store can only register one callback for each action.');
198
+ action = dispatch.action, after = dispatch.after, callback = dispatch.callback;
199
+ assert(!_this.storeImpl.dispatcherIdsByAction[action.hippoName], 'Each store can only register one callback for each action.');
196
200
  if (typeof callback === 'string') {
197
- callback = _this[callback];
201
+ callback = _this.storeImpl[callback];
198
202
  }
199
- callback = callback.bind(_this);
203
+ callback = callback.bind(_this.storeImpl);
200
204
  id = Hippodrome.Dispatcher.register(_this, action.hippoName, after, callback);
201
- return _this.dispatcherIdsByAction[action.hippoName] = id;
205
+ return _this.storeImpl.dispatcherIdsByAction[action.hippoName] = id;
202
206
  };
203
207
  })(this));
204
208
  }
@@ -206,11 +210,11 @@
206
210
  };
207
211
 
208
212
  Store.prototype.register = function(callback) {
209
- return this.callbacks.push(callback);
213
+ return this.storeImpl.callbacks.push(callback);
210
214
  };
211
215
 
212
216
  Store.prototype.unregister = function(callback) {
213
- return this.callbacks = _.reject(this.callbacks, function(cb) {
217
+ return this.storeImpl.callbacks = _.reject(this.storeImpl.callbacks, function(cb) {
214
218
  return cb === callback;
215
219
  });
216
220
  };
@@ -229,7 +233,7 @@
229
233
  };
230
234
 
231
235
  Store.prototype.trigger = function() {
232
- return _.forEach(this.callbacks, function(callback) {
236
+ return _.forEach(this.storeImpl.callbacks, function(callback) {
233
237
  return callback();
234
238
  });
235
239
  };
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.0.16
4
+ version: 0.0.18
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-10-23 00:00:00.000000000 Z
12
+ date: 2014-10-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler