flux-rails-assets 1.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 935a1ec40de0bdd71ce9bb919cf43cab1d3333d5
4
+ data.tar.gz: ecdbaad6ea9a94059047622fbc9c4f819ace24af
5
+ SHA512:
6
+ metadata.gz: 0b9146e89ce192d225fe1ada11a503d18c4db9a9a4281c303a89a75b152c38f86074b6f1810d743d7bd4842819afd1bc507cf647bf7542b56de736d9e8b2ac30
7
+ data.tar.gz: 0ab038d6b12c6b5c076a5232149a86e9936a298201143aeef8caacb544726220862482fdee6e6be45e25a47dc09fb3fbd7672d1f31677e560a22c847bd0984d1
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Stefan Ritter
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # flux-rails-assets
2
+
3
+ [Flux](https://github.com/facebook/flux) and [Node EventEmitter](https://github.com/joyent/node) for Rails Asset Pipeline for use with [react-rails gem](https://github.com/reactjs/react-rails)
4
+
5
+ Doesn't use CommonJS instead it creates FluxDispatcher and EventEmitter on window to easily work with [sprockets-rails](https://github.com/rails/sprockets-rails) Assets Pipeline.
6
+
7
+ Works well with react-rails server side rendering.
8
+
9
+ - Flux version: [2.0.2](https://github.com/facebook/flux/releases/tag/2.0.2)
10
+
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'flux-rails-assets'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install flux-rails-assets
27
+
28
+
29
+ ## Usage
30
+
31
+ Require flux and the eventemitter in your application.js:
32
+
33
+ ```js
34
+ //= require flux
35
+ //= require eventemitter
36
+ ```
37
+
38
+ This will create two globals you can use to create your application's dispatcher and stores:
39
+
40
+ ```js
41
+ var AppDispatcher = new FluxDispatcher();
42
+
43
+ var ExampleStore = new EventEmitter();
44
+
45
+ ExampleStore.dispatchToken = AppDispatcher.register(function (payload) {
46
+ var action = payload.action;
47
+
48
+ switch(action.type) {
49
+
50
+ case 'EXAMPLE_ACTION':
51
+ ExampleStore.emitChange();
52
+ break;
53
+
54
+ default:
55
+ // do nothing
56
+ }
57
+ });
58
+
59
+ ```
60
+
61
+
62
+ ## Credits
63
+
64
+ [Flux](https://github.com/facebook/flux) by [Facebook](http://www.facebook.com)
65
+ [Node EventEmitter](https://github.com/joyent/node) by [Joyent](https://www.joyent.com/)
66
+
67
+ Written by [Stefan Ritter](https://github.com/stefanitter), released under the [MIT license](https://github.com/mariopeixoto/flux-rails/LICENSE).
@@ -0,0 +1,7 @@
1
+ module FluxRailsAssets
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ # Get rails to add app, lib, vendor to load path
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,308 @@
1
+ // Copyright Joyent, Inc. and other Node contributors.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a
4
+ // copy of this software and associated documentation files (the
5
+ // "Software"), to deal in the Software without restriction, including
6
+ // without limitation the rights to use, copy, modify, merge, publish,
7
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
8
+ // persons to whom the Software is furnished to do so, subject to the
9
+ // following conditions:
10
+ //
11
+ // The above copyright notice and this permission notice shall be included
12
+ // in all copies or substantial portions of the Software.
13
+ //
14
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ (function () {
23
+
24
+ function EventEmitter() {
25
+ this._events = this._events || {};
26
+ this._maxListeners = this._maxListeners || undefined;
27
+ }
28
+
29
+ //module.exports = EventEmitter;
30
+ window.EventEmitter = EventEmitter;
31
+
32
+ // Backwards-compat with node 0.10.x
33
+ EventEmitter.EventEmitter = EventEmitter;
34
+
35
+ EventEmitter.prototype._events = undefined;
36
+ EventEmitter.prototype._maxListeners = undefined;
37
+
38
+ // By default EventEmitters will print a warning if more than 10 listeners are
39
+ // added to it. This is a useful default which helps finding memory leaks.
40
+ EventEmitter.defaultMaxListeners = 10;
41
+
42
+ // Obviously not all Emitters should be limited to 10. This function allows
43
+ // that to be increased. Set to zero for unlimited.
44
+ EventEmitter.prototype.setMaxListeners = function(n) {
45
+ if (!isNumber(n) || n < 0 || isNaN(n))
46
+ throw TypeError('n must be a positive number');
47
+ this._maxListeners = n;
48
+ return this;
49
+ };
50
+
51
+ EventEmitter.prototype.emit = function(type) {
52
+ var er, handler, len, args, i, listeners;
53
+
54
+ if (!this._events)
55
+ this._events = {};
56
+
57
+ // If there is no 'error' event listener then throw.
58
+ if (type === 'error') {
59
+ if (!this._events.error ||
60
+ (isObject(this._events.error) && !this._events.error.length)) {
61
+ er = arguments[1];
62
+ if (er instanceof Error) {
63
+ throw er; // Unhandled 'error' event
64
+ } else {
65
+ throw TypeError('Uncaught, unspecified "error" event.');
66
+ }
67
+ return false;
68
+ }
69
+ }
70
+
71
+ handler = this._events[type];
72
+
73
+ if (isUndefined(handler))
74
+ return false;
75
+
76
+ if (isFunction(handler)) {
77
+ switch (arguments.length) {
78
+ // fast cases
79
+ case 1:
80
+ handler.call(this);
81
+ break;
82
+ case 2:
83
+ handler.call(this, arguments[1]);
84
+ break;
85
+ case 3:
86
+ handler.call(this, arguments[1], arguments[2]);
87
+ break;
88
+ // slower
89
+ default:
90
+ len = arguments.length;
91
+ args = new Array(len - 1);
92
+ for (i = 1; i < len; i++)
93
+ args[i - 1] = arguments[i];
94
+ handler.apply(this, args);
95
+ }
96
+ } else if (isObject(handler)) {
97
+ len = arguments.length;
98
+ args = new Array(len - 1);
99
+ for (i = 1; i < len; i++)
100
+ args[i - 1] = arguments[i];
101
+
102
+ listeners = handler.slice();
103
+ len = listeners.length;
104
+ for (i = 0; i < len; i++)
105
+ listeners[i].apply(this, args);
106
+ }
107
+
108
+ return true;
109
+ };
110
+
111
+ EventEmitter.prototype.addListener = function(type, listener) {
112
+ var m;
113
+
114
+ if (!isFunction(listener))
115
+ throw TypeError('listener must be a function');
116
+
117
+ if (!this._events)
118
+ this._events = {};
119
+
120
+ // To avoid recursion in the case that type === "newListener"! Before
121
+ // adding it to the listeners, first emit "newListener".
122
+ if (this._events.newListener)
123
+ this.emit('newListener', type,
124
+ isFunction(listener.listener) ?
125
+ listener.listener : listener);
126
+
127
+ if (!this._events[type])
128
+ // Optimize the case of one listener. Don't need the extra array object.
129
+ this._events[type] = listener;
130
+ else if (isObject(this._events[type]))
131
+ // If we've already got an array, just append.
132
+ this._events[type].push(listener);
133
+ else
134
+ // Adding the second element, need to change to array.
135
+ this._events[type] = [this._events[type], listener];
136
+
137
+ // Check for listener leak
138
+ if (isObject(this._events[type]) && !this._events[type].warned) {
139
+ var m;
140
+ if (!isUndefined(this._maxListeners)) {
141
+ m = this._maxListeners;
142
+ } else {
143
+ m = EventEmitter.defaultMaxListeners;
144
+ }
145
+
146
+ if (m && m > 0 && this._events[type].length > m) {
147
+ this._events[type].warned = true;
148
+ console.error('(node) warning: possible EventEmitter memory ' +
149
+ 'leak detected. %d listeners added. ' +
150
+ 'Use emitter.setMaxListeners() to increase limit.',
151
+ this._events[type].length);
152
+ if (typeof console.trace === 'function') {
153
+ // not supported in IE 10
154
+ console.trace();
155
+ }
156
+ }
157
+ }
158
+
159
+ return this;
160
+ };
161
+
162
+ EventEmitter.prototype.on = EventEmitter.prototype.addListener;
163
+
164
+ EventEmitter.prototype.once = function(type, listener) {
165
+ if (!isFunction(listener))
166
+ throw TypeError('listener must be a function');
167
+
168
+ var fired = false;
169
+
170
+ function g() {
171
+ this.removeListener(type, g);
172
+
173
+ if (!fired) {
174
+ fired = true;
175
+ listener.apply(this, arguments);
176
+ }
177
+ }
178
+
179
+ g.listener = listener;
180
+ this.on(type, g);
181
+
182
+ return this;
183
+ };
184
+
185
+ // emits a 'removeListener' event iff the listener was removed
186
+ EventEmitter.prototype.removeListener = function(type, listener) {
187
+ var list, position, length, i;
188
+
189
+ if (!isFunction(listener))
190
+ throw TypeError('listener must be a function');
191
+
192
+ if (!this._events || !this._events[type])
193
+ return this;
194
+
195
+ list = this._events[type];
196
+ length = list.length;
197
+ position = -1;
198
+
199
+ if (list === listener ||
200
+ (isFunction(list.listener) && list.listener === listener)) {
201
+ delete this._events[type];
202
+ if (this._events.removeListener)
203
+ this.emit('removeListener', type, listener);
204
+
205
+ } else if (isObject(list)) {
206
+ for (i = length; i-- > 0;) {
207
+ if (list[i] === listener ||
208
+ (list[i].listener && list[i].listener === listener)) {
209
+ position = i;
210
+ break;
211
+ }
212
+ }
213
+
214
+ if (position < 0)
215
+ return this;
216
+
217
+ if (list.length === 1) {
218
+ list.length = 0;
219
+ delete this._events[type];
220
+ } else {
221
+ list.splice(position, 1);
222
+ }
223
+
224
+ if (this._events.removeListener)
225
+ this.emit('removeListener', type, listener);
226
+ }
227
+
228
+ return this;
229
+ };
230
+
231
+ EventEmitter.prototype.removeAllListeners = function(type) {
232
+ var key, listeners;
233
+
234
+ if (!this._events)
235
+ return this;
236
+
237
+ // not listening for removeListener, no need to emit
238
+ if (!this._events.removeListener) {
239
+ if (arguments.length === 0)
240
+ this._events = {};
241
+ else if (this._events[type])
242
+ delete this._events[type];
243
+ return this;
244
+ }
245
+
246
+ // emit removeListener for all listeners on all events
247
+ if (arguments.length === 0) {
248
+ for (key in this._events) {
249
+ if (key === 'removeListener') continue;
250
+ this.removeAllListeners(key);
251
+ }
252
+ this.removeAllListeners('removeListener');
253
+ this._events = {};
254
+ return this;
255
+ }
256
+
257
+ listeners = this._events[type];
258
+
259
+ if (isFunction(listeners)) {
260
+ this.removeListener(type, listeners);
261
+ } else {
262
+ // LIFO order
263
+ while (listeners.length)
264
+ this.removeListener(type, listeners[listeners.length - 1]);
265
+ }
266
+ delete this._events[type];
267
+
268
+ return this;
269
+ };
270
+
271
+ EventEmitter.prototype.listeners = function(type) {
272
+ var ret;
273
+ if (!this._events || !this._events[type])
274
+ ret = [];
275
+ else if (isFunction(this._events[type]))
276
+ ret = [this._events[type]];
277
+ else
278
+ ret = this._events[type].slice();
279
+ return ret;
280
+ };
281
+
282
+ EventEmitter.listenerCount = function(emitter, type) {
283
+ var ret;
284
+ if (!emitter._events || !emitter._events[type])
285
+ ret = 0;
286
+ else if (isFunction(emitter._events[type]))
287
+ ret = 1;
288
+ else
289
+ ret = emitter._events[type].length;
290
+ return ret;
291
+ };
292
+
293
+ function isFunction(arg) {
294
+ return typeof arg === 'function';
295
+ }
296
+
297
+ function isNumber(arg) {
298
+ return typeof arg === 'number';
299
+ }
300
+
301
+ function isObject(arg) {
302
+ return typeof arg === 'object' && arg !== null;
303
+ }
304
+
305
+ function isUndefined(arg) {
306
+ return arg === void 0;
307
+ }
308
+ })();
@@ -0,0 +1,320 @@
1
+ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Flux=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
+ /**
3
+ * Copyright (c) 2014, Facebook, Inc.
4
+ * All rights reserved.
5
+ *
6
+ * This source code is licensed under the BSD-style license found in the
7
+ * LICENSE file in the root directory of this source tree. An additional grant
8
+ * of patent rights can be found in the PATENTS file in the same directory.
9
+ */
10
+
11
+ module.exports.Dispatcher = require('./lib/Dispatcher')
12
+ window.FluxDispatcher = module.exports.Dispatcher
13
+
14
+ },{"./lib/Dispatcher":2}],2:[function(require,module,exports){
15
+ /*
16
+ * Copyright (c) 2014, Facebook, Inc.
17
+ * All rights reserved.
18
+ *
19
+ * This source code is licensed under the BSD-style license found in the
20
+ * LICENSE file in the root directory of this source tree. An additional grant
21
+ * of patent rights can be found in the PATENTS file in the same directory.
22
+ *
23
+ * @providesModule Dispatcher
24
+ * @typechecks
25
+ */
26
+
27
+ var invariant = require('./invariant');
28
+
29
+ var _lastID = 1;
30
+ var _prefix = 'ID_';
31
+
32
+ /**
33
+ * Dispatcher is used to broadcast payloads to registered callbacks. This is
34
+ * different from generic pub-sub systems in two ways:
35
+ *
36
+ * 1) Callbacks are not subscribed to particular events. Every payload is
37
+ * dispatched to every registered callback.
38
+ * 2) Callbacks can be deferred in whole or part until other callbacks have
39
+ * been executed.
40
+ *
41
+ * For example, consider this hypothetical flight destination form, which
42
+ * selects a default city when a country is selected:
43
+ *
44
+ * var flightDispatcher = new Dispatcher();
45
+ *
46
+ * // Keeps track of which country is selected
47
+ * var CountryStore = {country: null};
48
+ *
49
+ * // Keeps track of which city is selected
50
+ * var CityStore = {city: null};
51
+ *
52
+ * // Keeps track of the base flight price of the selected city
53
+ * var FlightPriceStore = {price: null}
54
+ *
55
+ * When a user changes the selected city, we dispatch the payload:
56
+ *
57
+ * flightDispatcher.dispatch({
58
+ * actionType: 'city-update',
59
+ * selectedCity: 'paris'
60
+ * });
61
+ *
62
+ * This payload is digested by `CityStore`:
63
+ *
64
+ * flightDispatcher.register(function(payload)) {
65
+ * if (payload.actionType === 'city-update') {
66
+ * CityStore.city = payload.selectedCity;
67
+ * }
68
+ * });
69
+ *
70
+ * When the user selects a country, we dispatch the payload:
71
+ *
72
+ * flightDispatcher.dispatch({
73
+ * actionType: 'country-update',
74
+ * selectedCountry: 'australia'
75
+ * });
76
+ *
77
+ * This payload is digested by both stores:
78
+ *
79
+ * CountryStore.dispatchToken = flightDispatcher.register(function(payload) {
80
+ * if (payload.actionType === 'country-update') {
81
+ * CountryStore.country = payload.selectedCountry;
82
+ * }
83
+ * });
84
+ *
85
+ * When the callback to update `CountryStore` is registered, we save a reference
86
+ * to the returned token. Using this token with `waitFor()`, we can guarantee
87
+ * that `CountryStore` is updated before the callback that updates `CityStore`
88
+ * needs to query its data.
89
+ *
90
+ * CityStore.dispatchToken = flightDispatcher.register(function(payload) {
91
+ * if (payload.actionType === 'country-update') {
92
+ * // `CountryStore.country` may not be updated.
93
+ * flightDispatcher.waitFor([CountryStore.dispatchToken]);
94
+ * // `CountryStore.country` is now guaranteed to be updated.
95
+ *
96
+ * // Select the default city for the new country
97
+ * CityStore.city = getDefaultCityForCountry(CountryStore.country);
98
+ * }
99
+ * });
100
+ *
101
+ * The usage of `waitFor()` can be chained, for example:
102
+ *
103
+ * FlightPriceStore.dispatchToken =
104
+ * flightDispatcher.register(function(payload)) {
105
+ * switch (payload.actionType) {
106
+ * case 'country-update':
107
+ * flightDispatcher.waitFor([CityStore.dispatchToken]);
108
+ * FlightPriceStore.price =
109
+ * getFlightPriceStore(CountryStore.country, CityStore.city);
110
+ * break;
111
+ *
112
+ * case 'city-update':
113
+ * FlightPriceStore.price =
114
+ * FlightPriceStore(CountryStore.country, CityStore.city);
115
+ * break;
116
+ * }
117
+ * });
118
+ *
119
+ * The `country-update` payload will be guaranteed to invoke the stores'
120
+ * registered callbacks in order: `CountryStore`, `CityStore`, then
121
+ * `FlightPriceStore`.
122
+ */
123
+
124
+ function Dispatcher() {"use strict";
125
+ this.$Dispatcher_callbacks = {};
126
+ this.$Dispatcher_isPending = {};
127
+ this.$Dispatcher_isHandled = {};
128
+ this.$Dispatcher_isDispatching = false;
129
+ this.$Dispatcher_pendingPayload = null;
130
+ }
131
+
132
+ /**
133
+ * Registers a callback to be invoked with every dispatched payload. Returns
134
+ * a token that can be used with `waitFor()`.
135
+ *
136
+ * @param {function} callback
137
+ * @return {string}
138
+ */
139
+ Dispatcher.prototype.register=function(callback) {"use strict";
140
+ var id = _prefix + _lastID++;
141
+ this.$Dispatcher_callbacks[id] = callback;
142
+ return id;
143
+ };
144
+
145
+ /**
146
+ * Removes a callback based on its token.
147
+ *
148
+ * @param {string} id
149
+ */
150
+ Dispatcher.prototype.unregister=function(id) {"use strict";
151
+ invariant(
152
+ this.$Dispatcher_callbacks[id],
153
+ 'Dispatcher.unregister(...): `%s` does not map to a registered callback.',
154
+ id
155
+ );
156
+ delete this.$Dispatcher_callbacks[id];
157
+ };
158
+
159
+ /**
160
+ * Waits for the callbacks specified to be invoked before continuing execution
161
+ * of the current callback. This method should only be used by a callback in
162
+ * response to a dispatched payload.
163
+ *
164
+ * @param {array<string>} ids
165
+ */
166
+ Dispatcher.prototype.waitFor=function(ids) {"use strict";
167
+ invariant(
168
+ this.$Dispatcher_isDispatching,
169
+ 'Dispatcher.waitFor(...): Must be invoked while dispatching.'
170
+ );
171
+ for (var ii = 0; ii < ids.length; ii++) {
172
+ var id = ids[ii];
173
+ if (this.$Dispatcher_isPending[id]) {
174
+ invariant(
175
+ this.$Dispatcher_isHandled[id],
176
+ 'Dispatcher.waitFor(...): Circular dependency detected while ' +
177
+ 'waiting for `%s`.',
178
+ id
179
+ );
180
+ continue;
181
+ }
182
+ invariant(
183
+ this.$Dispatcher_callbacks[id],
184
+ 'Dispatcher.waitFor(...): `%s` does not map to a registered callback.',
185
+ id
186
+ );
187
+ this.$Dispatcher_invokeCallback(id);
188
+ }
189
+ };
190
+
191
+ /**
192
+ * Dispatches a payload to all registered callbacks.
193
+ *
194
+ * @param {object} payload
195
+ */
196
+ Dispatcher.prototype.dispatch=function(payload) {"use strict";
197
+ invariant(
198
+ !this.$Dispatcher_isDispatching,
199
+ 'Dispatch.dispatch(...): Cannot dispatch in the middle of a dispatch.'
200
+ );
201
+ this.$Dispatcher_startDispatching(payload);
202
+ try {
203
+ for (var id in this.$Dispatcher_callbacks) {
204
+ if (this.$Dispatcher_isPending[id]) {
205
+ continue;
206
+ }
207
+ this.$Dispatcher_invokeCallback(id);
208
+ }
209
+ } finally {
210
+ this.$Dispatcher_stopDispatching();
211
+ }
212
+ };
213
+
214
+ /**
215
+ * Is this Dispatcher currently dispatching.
216
+ *
217
+ * @return {boolean}
218
+ */
219
+ Dispatcher.prototype.isDispatching=function() {"use strict";
220
+ return this.$Dispatcher_isDispatching;
221
+ };
222
+
223
+ /**
224
+ * Call the callback stored with the given id. Also do some internal
225
+ * bookkeeping.
226
+ *
227
+ * @param {string} id
228
+ * @internal
229
+ */
230
+ Dispatcher.prototype.$Dispatcher_invokeCallback=function(id) {"use strict";
231
+ this.$Dispatcher_isPending[id] = true;
232
+ this.$Dispatcher_callbacks[id](this.$Dispatcher_pendingPayload);
233
+ this.$Dispatcher_isHandled[id] = true;
234
+ };
235
+
236
+ /**
237
+ * Set up bookkeeping needed when dispatching.
238
+ *
239
+ * @param {object} payload
240
+ * @internal
241
+ */
242
+ Dispatcher.prototype.$Dispatcher_startDispatching=function(payload) {"use strict";
243
+ for (var id in this.$Dispatcher_callbacks) {
244
+ this.$Dispatcher_isPending[id] = false;
245
+ this.$Dispatcher_isHandled[id] = false;
246
+ }
247
+ this.$Dispatcher_pendingPayload = payload;
248
+ this.$Dispatcher_isDispatching = true;
249
+ };
250
+
251
+ /**
252
+ * Clear bookkeeping used for dispatching.
253
+ *
254
+ * @internal
255
+ */
256
+ Dispatcher.prototype.$Dispatcher_stopDispatching=function() {"use strict";
257
+ this.$Dispatcher_pendingPayload = null;
258
+ this.$Dispatcher_isDispatching = false;
259
+ };
260
+
261
+
262
+ module.exports = Dispatcher;
263
+
264
+ },{"./invariant":3}],3:[function(require,module,exports){
265
+ /**
266
+ * Copyright (c) 2014, Facebook, Inc.
267
+ * All rights reserved.
268
+ *
269
+ * This source code is licensed under the BSD-style license found in the
270
+ * LICENSE file in the root directory of this source tree. An additional grant
271
+ * of patent rights can be found in the PATENTS file in the same directory.
272
+ *
273
+ * @providesModule invariant
274
+ */
275
+
276
+ "use strict";
277
+
278
+ /**
279
+ * Use invariant() to assert state which your program assumes to be true.
280
+ *
281
+ * Provide sprintf-style format (only %s is supported) and arguments
282
+ * to provide information about what broke and what you were
283
+ * expecting.
284
+ *
285
+ * The invariant message will be stripped in production, but the invariant
286
+ * will remain to ensure logic does not differ in production.
287
+ */
288
+
289
+ var invariant = function(condition, format, a, b, c, d, e, f) {
290
+ if (false) {
291
+ if (format === undefined) {
292
+ throw new Error('invariant requires an error message argument');
293
+ }
294
+ }
295
+
296
+ if (!condition) {
297
+ var error;
298
+ if (format === undefined) {
299
+ error = new Error(
300
+ 'Minified exception occurred; use the non-minified dev environment ' +
301
+ 'for the full error message and additional helpful warnings.'
302
+ );
303
+ } else {
304
+ var args = [a, b, c, d, e, f];
305
+ var argIndex = 0;
306
+ error = new Error(
307
+ 'Invariant Violation: ' +
308
+ format.replace(/%s/g, function() { return args[argIndex++]; })
309
+ );
310
+ }
311
+
312
+ error.framesToPop = 1; // we don't care about invariant's own frame
313
+ throw error;
314
+ }
315
+ };
316
+
317
+ module.exports = invariant;
318
+
319
+ },{}]},{},[1])(1)
320
+ });
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flux-rails-assets
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Stefan Ritter
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '3.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 3.2.12
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 3.2.12
41
+ description: Use Facebook's Flux dispatcher and Node EventEmitter in your Rails project.
42
+ email:
43
+ - stefan@stefanritter.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - LICENSE.txt
49
+ - README.md
50
+ - lib/flux-rails-assets.rb
51
+ - vendor/assets/javascript/eventemitter.js
52
+ - vendor/assets/javascript/flux.js
53
+ homepage: https://github.com/stefanritter/flux-rails-assets
54
+ licenses:
55
+ - MIT
56
+ metadata: {}
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubyforge_project:
73
+ rubygems_version: 2.2.2
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: Flux dispatcher and Node Event Emitter for the Ruby on Rails asset pipeline
77
+ test_files: []