flux-rails 0.0.1 → 2.0.2
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/README.md +22 -7
- data/lib/flux/rails/version.rb +1 -1
- data/vendor/assets/javascript/flux.js +39 -36
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e888fccd2c051cfef1ef26efd33ee0c0b164fe9
|
4
|
+
data.tar.gz: dd88520658afa906fe9124b886d6a02af89e5a31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 700a132a520c67ac9953a4e89ac734658a3aebc5aa07094a6370cedb040d87a56fca18cbf8a62c751282feec4518acd5f0e032135cf78e9cd18639a304c7cfcc
|
7
|
+
data.tar.gz: cdc2e7f07c6b5ba2d4a3d08806ab9bb66c1868340bfc4a6a297a18064493ed654b64afc92a425e0c376459dfe56c598f6d036126252a91e41d6b76551c9ac6ec
|
data/README.md
CHANGED
@@ -1,14 +1,19 @@
|
|
1
|
-
#
|
1
|
+
# flux-rails
|
2
|
+
|
3
|
+
[](https://badge.fury.io/rb/flux-rails.svg)
|
4
|
+
|
5
|
+
[Flux](https://github.com/facebook/flux) for Rails Asset Pipeline
|
6
|
+
|
7
|
+
- Flux version: [2.0.2](https://github.com/facebook/flux/releases/tag/2.0.2)
|
2
8
|
|
3
|
-
TODO: Write a gem description
|
4
9
|
|
5
10
|
## Installation
|
6
11
|
|
7
12
|
Add this line to your application's Gemfile:
|
8
13
|
|
9
|
-
```ruby
|
10
|
-
gem 'flux-rails'
|
11
|
-
```
|
14
|
+
```ruby
|
15
|
+
gem 'flux-rails'
|
16
|
+
```
|
12
17
|
|
13
18
|
And then execute:
|
14
19
|
|
@@ -20,12 +25,22 @@ Or install it yourself as:
|
|
20
25
|
|
21
26
|
## Usage
|
22
27
|
|
23
|
-
|
28
|
+
Require flux in your application.js
|
29
|
+
|
30
|
+
```js
|
31
|
+
//= require flux
|
32
|
+
```
|
24
33
|
|
25
34
|
## Contributing
|
26
35
|
|
27
|
-
1. Fork it ( https://github.com/
|
36
|
+
1. Fork it ( https://github.com/mariopeixoto/flux-rails/fork )
|
28
37
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
38
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
39
|
4. Push to the branch (`git push origin my-new-feature`)
|
31
40
|
5. Create a new Pull Request
|
41
|
+
|
42
|
+
## Acknowledgements
|
43
|
+
|
44
|
+
[Flux](https://github.com/facebook/flux) by [Facebook](http://www.facebook.com)
|
45
|
+
|
46
|
+
Copyright [Mario Peixoto](https://github.com/mariopeixoto), released under the [MIT license](https://github.com/mariopeixoto/flux-rails/LICENSE).
|
data/lib/flux/rails/version.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
module.exports.Dispatcher = require('./lib/Dispatcher')
|
12
12
|
|
13
13
|
},{"./lib/Dispatcher":2}],2:[function(require,module,exports){
|
14
|
-
|
14
|
+
/*
|
15
15
|
* Copyright (c) 2014, Facebook, Inc.
|
16
16
|
* All rights reserved.
|
17
17
|
*
|
@@ -21,7 +21,6 @@ module.exports.Dispatcher = require('./lib/Dispatcher')
|
|
21
21
|
*
|
22
22
|
* @providesModule Dispatcher
|
23
23
|
* @typechecks
|
24
|
-
* @preventMunge
|
25
24
|
*/
|
26
25
|
|
27
26
|
"use strict";
|
@@ -106,11 +105,15 @@ var _prefix = 'ID_';
|
|
106
105
|
* flightDispatcher.register(function(payload) {
|
107
106
|
* switch (payload.actionType) {
|
108
107
|
* case 'country-update':
|
109
|
-
* case 'city-update':
|
110
108
|
* flightDispatcher.waitFor([CityStore.dispatchToken]);
|
111
109
|
* FlightPriceStore.price =
|
112
110
|
* getFlightPriceStore(CountryStore.country, CityStore.city);
|
113
111
|
* break;
|
112
|
+
*
|
113
|
+
* case 'city-update':
|
114
|
+
* FlightPriceStore.price =
|
115
|
+
* FlightPriceStore(CountryStore.country, CityStore.city);
|
116
|
+
* break;
|
114
117
|
* }
|
115
118
|
* });
|
116
119
|
*
|
@@ -120,11 +123,11 @@ var _prefix = 'ID_';
|
|
120
123
|
*/
|
121
124
|
|
122
125
|
function Dispatcher() {
|
123
|
-
this
|
124
|
-
this
|
125
|
-
this
|
126
|
-
this
|
127
|
-
this
|
126
|
+
this.$Dispatcher_callbacks = {};
|
127
|
+
this.$Dispatcher_isPending = {};
|
128
|
+
this.$Dispatcher_isHandled = {};
|
129
|
+
this.$Dispatcher_isDispatching = false;
|
130
|
+
this.$Dispatcher_pendingPayload = null;
|
128
131
|
}
|
129
132
|
|
130
133
|
/**
|
@@ -136,7 +139,7 @@ var _prefix = 'ID_';
|
|
136
139
|
*/
|
137
140
|
Dispatcher.prototype.register=function(callback) {
|
138
141
|
var id = _prefix + _lastID++;
|
139
|
-
this
|
142
|
+
this.$Dispatcher_callbacks[id] = callback;
|
140
143
|
return id;
|
141
144
|
};
|
142
145
|
|
@@ -147,11 +150,11 @@ var _prefix = 'ID_';
|
|
147
150
|
*/
|
148
151
|
Dispatcher.prototype.unregister=function(id) {
|
149
152
|
invariant(
|
150
|
-
this
|
153
|
+
this.$Dispatcher_callbacks[id],
|
151
154
|
'Dispatcher.unregister(...): `%s` does not map to a registered callback.',
|
152
155
|
id
|
153
156
|
);
|
154
|
-
delete this
|
157
|
+
delete this.$Dispatcher_callbacks[id];
|
155
158
|
};
|
156
159
|
|
157
160
|
/**
|
@@ -163,14 +166,14 @@ var _prefix = 'ID_';
|
|
163
166
|
*/
|
164
167
|
Dispatcher.prototype.waitFor=function(ids) {
|
165
168
|
invariant(
|
166
|
-
this
|
169
|
+
this.$Dispatcher_isDispatching,
|
167
170
|
'Dispatcher.waitFor(...): Must be invoked while dispatching.'
|
168
171
|
);
|
169
172
|
for (var ii = 0; ii < ids.length; ii++) {
|
170
173
|
var id = ids[ii];
|
171
|
-
if (this
|
174
|
+
if (this.$Dispatcher_isPending[id]) {
|
172
175
|
invariant(
|
173
|
-
this
|
176
|
+
this.$Dispatcher_isHandled[id],
|
174
177
|
'Dispatcher.waitFor(...): Circular dependency detected while ' +
|
175
178
|
'waiting for `%s`.',
|
176
179
|
id
|
@@ -178,11 +181,11 @@ var _prefix = 'ID_';
|
|
178
181
|
continue;
|
179
182
|
}
|
180
183
|
invariant(
|
181
|
-
this
|
184
|
+
this.$Dispatcher_callbacks[id],
|
182
185
|
'Dispatcher.waitFor(...): `%s` does not map to a registered callback.',
|
183
186
|
id
|
184
187
|
);
|
185
|
-
this
|
188
|
+
this.$Dispatcher_invokeCallback(id);
|
186
189
|
}
|
187
190
|
};
|
188
191
|
|
@@ -193,19 +196,19 @@ var _prefix = 'ID_';
|
|
193
196
|
*/
|
194
197
|
Dispatcher.prototype.dispatch=function(payload) {
|
195
198
|
invariant(
|
196
|
-
!this
|
199
|
+
!this.$Dispatcher_isDispatching,
|
197
200
|
'Dispatch.dispatch(...): Cannot dispatch in the middle of a dispatch.'
|
198
201
|
);
|
199
|
-
this
|
202
|
+
this.$Dispatcher_startDispatching(payload);
|
200
203
|
try {
|
201
|
-
for (var id in this
|
202
|
-
if (this
|
204
|
+
for (var id in this.$Dispatcher_callbacks) {
|
205
|
+
if (this.$Dispatcher_isPending[id]) {
|
203
206
|
continue;
|
204
207
|
}
|
205
|
-
this
|
208
|
+
this.$Dispatcher_invokeCallback(id);
|
206
209
|
}
|
207
210
|
} finally {
|
208
|
-
this
|
211
|
+
this.$Dispatcher_stopDispatching();
|
209
212
|
}
|
210
213
|
};
|
211
214
|
|
@@ -215,7 +218,7 @@ var _prefix = 'ID_';
|
|
215
218
|
* @return {boolean}
|
216
219
|
*/
|
217
220
|
Dispatcher.prototype.isDispatching=function() {
|
218
|
-
return this
|
221
|
+
return this.$Dispatcher_isDispatching;
|
219
222
|
};
|
220
223
|
|
221
224
|
/**
|
@@ -225,10 +228,10 @@ var _prefix = 'ID_';
|
|
225
228
|
* @param {string} id
|
226
229
|
* @internal
|
227
230
|
*/
|
228
|
-
Dispatcher.prototype
|
229
|
-
this
|
230
|
-
this
|
231
|
-
this
|
231
|
+
Dispatcher.prototype.$Dispatcher_invokeCallback=function(id) {
|
232
|
+
this.$Dispatcher_isPending[id] = true;
|
233
|
+
this.$Dispatcher_callbacks[id](this.$Dispatcher_pendingPayload);
|
234
|
+
this.$Dispatcher_isHandled[id] = true;
|
232
235
|
};
|
233
236
|
|
234
237
|
/**
|
@@ -237,13 +240,13 @@ var _prefix = 'ID_';
|
|
237
240
|
* @param {object} payload
|
238
241
|
* @internal
|
239
242
|
*/
|
240
|
-
Dispatcher.prototype
|
241
|
-
for (var id in this
|
242
|
-
this
|
243
|
-
this
|
243
|
+
Dispatcher.prototype.$Dispatcher_startDispatching=function(payload) {
|
244
|
+
for (var id in this.$Dispatcher_callbacks) {
|
245
|
+
this.$Dispatcher_isPending[id] = false;
|
246
|
+
this.$Dispatcher_isHandled[id] = false;
|
244
247
|
}
|
245
|
-
this
|
246
|
-
this
|
248
|
+
this.$Dispatcher_pendingPayload = payload;
|
249
|
+
this.$Dispatcher_isDispatching = true;
|
247
250
|
};
|
248
251
|
|
249
252
|
/**
|
@@ -251,9 +254,9 @@ var _prefix = 'ID_';
|
|
251
254
|
*
|
252
255
|
* @internal
|
253
256
|
*/
|
254
|
-
Dispatcher.prototype
|
255
|
-
this
|
256
|
-
this
|
257
|
+
Dispatcher.prototype.$Dispatcher_stopDispatching=function() {
|
258
|
+
this.$Dispatcher_pendingPayload = null;
|
259
|
+
this.$Dispatcher_isDispatching = false;
|
257
260
|
};
|
258
261
|
|
259
262
|
|