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 +4 -4
- data/app/assets/javascripts/hippodrome.js +29 -25
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b5036e5c66a8704fd400c621f9c369e0ed3d4d4
|
4
|
+
data.tar.gz: e5c3b2aabd0e7b4adefce19d8c1c8d84032e7393
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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,
|
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
|
-
|
157
|
-
var action,
|
158
|
-
assert(options.action, '
|
159
|
-
assert(options.
|
160
|
-
action = options.action,
|
161
|
-
if (typeof
|
162
|
-
|
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
|
-
|
165
|
-
id = Hippodrome.Dispatcher.register(this, action.hippoName, [],
|
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.
|
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.
|
185
|
-
this.
|
186
|
-
|
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(
|
196
|
+
return function(dispatch) {
|
193
197
|
var action, after, callback, id;
|
194
|
-
action =
|
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.
|
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-
|
12
|
+
date: 2014-10-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|