rxjs-rails 2.3.10 → 2.3.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rxjs/rails/version.rb +1 -1
  3. data/vendor/assets/javascripts/rx.aggregates.js +120 -70
  4. data/vendor/assets/javascripts/rx.aggregates.min.js +3 -1
  5. data/vendor/assets/javascripts/rx.all.compat.js +1810 -1849
  6. data/vendor/assets/javascripts/rx.all.compat.min.js +5 -3
  7. data/vendor/assets/javascripts/rx.all.js +1776 -1815
  8. data/vendor/assets/javascripts/rx.all.min.js +5 -3
  9. data/vendor/assets/javascripts/rx.async.compat.js +45 -45
  10. data/vendor/assets/javascripts/rx.async.compat.min.js +3 -1
  11. data/vendor/assets/javascripts/rx.async.js +39 -39
  12. data/vendor/assets/javascripts/rx.async.min.js +3 -1
  13. data/vendor/assets/javascripts/rx.backpressure.js +21 -19
  14. data/vendor/assets/javascripts/rx.backpressure.min.js +3 -1
  15. data/vendor/assets/javascripts/rx.binding.js +90 -90
  16. data/vendor/assets/javascripts/rx.binding.min.js +3 -1
  17. data/vendor/assets/javascripts/rx.coincidence.js +184 -179
  18. data/vendor/assets/javascripts/rx.coincidence.min.js +3 -1
  19. data/vendor/assets/javascripts/rx.compat.js +1019 -1001
  20. data/vendor/assets/javascripts/rx.compat.min.js +4 -2
  21. data/vendor/assets/javascripts/rx.experimental.js +65 -64
  22. data/vendor/assets/javascripts/rx.experimental.min.js +3 -1
  23. data/vendor/assets/javascripts/rx.joinpatterns.js +265 -363
  24. data/vendor/assets/javascripts/rx.joinpatterns.min.js +3 -1
  25. data/vendor/assets/javascripts/rx.js +969 -951
  26. data/vendor/assets/javascripts/rx.lite.compat.js +1014 -1182
  27. data/vendor/assets/javascripts/rx.lite.compat.min.js +4 -2
  28. data/vendor/assets/javascripts/rx.lite.extras.js +101 -109
  29. data/vendor/assets/javascripts/rx.lite.extras.min.js +3 -1
  30. data/vendor/assets/javascripts/rx.lite.js +1008 -1176
  31. data/vendor/assets/javascripts/rx.lite.min.js +4 -2
  32. data/vendor/assets/javascripts/rx.min.js +4 -2
  33. data/vendor/assets/javascripts/rx.testing.js +196 -196
  34. data/vendor/assets/javascripts/rx.testing.min.js +3 -1
  35. data/vendor/assets/javascripts/rx.time.js +162 -178
  36. data/vendor/assets/javascripts/rx.time.min.js +3 -1
  37. data/vendor/assets/javascripts/rx.virtualtime.js +30 -30
  38. data/vendor/assets/javascripts/rx.virtualtime.min.js +3 -1
  39. metadata +2 -6
  40. data/vendor/assets/javascripts/rx.core.compat.js +0 -2548
  41. data/vendor/assets/javascripts/rx.core.compat.min.js +0 -1
  42. data/vendor/assets/javascripts/rx.core.js +0 -2430
  43. data/vendor/assets/javascripts/rx.core.min.js +0 -1
@@ -1,4 +1,4 @@
1
- // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
1
+ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
2
2
 
3
3
  ;(function (factory) {
4
4
  var objectTypes = {
@@ -15,16 +15,15 @@
15
15
  freeModule = objectTypes[typeof module] && module && !module.nodeType && module,
16
16
  moduleExports = freeModule && freeModule.exports === freeExports && freeExports,
17
17
  freeGlobal = objectTypes[typeof global] && global;
18
-
18
+
19
19
  if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) {
20
20
  root = freeGlobal;
21
21
  }
22
22
 
23
23
  // Because of build optimizers
24
24
  if (typeof define === 'function' && define.amd) {
25
- define(['rx', 'exports'], function (Rx, exports) {
26
- root.Rx = factory(root, exports, Rx);
27
- return root.Rx;
25
+ define(['rx'], function (Rx, exports) {
26
+ return factory(root, exports, Rx);
28
27
  });
29
28
  } else if (typeof module === 'object' && module && module.exports === freeExports) {
30
29
  module.exports = factory(root, module.exports, require('./rx'));
@@ -32,323 +31,233 @@
32
31
  root.Rx = factory(root, {}, root.Rx);
33
32
  }
34
33
  }.call(this, function (root, exp, Rx, undefined) {
35
-
36
- // Aliases
37
- var Observable = Rx.Observable,
38
- observableProto = Observable.prototype,
39
- AnonymousObservable = Rx.AnonymousObservable,
40
- observableThrow = Observable.throwException,
41
- observerCreate = Rx.Observer.create,
42
- SingleAssignmentDisposable = Rx.SingleAssignmentDisposable,
43
- CompositeDisposable = Rx.CompositeDisposable,
44
- AbstractObserver = Rx.internals.AbstractObserver,
45
- noop = Rx.helpers.noop,
46
- defaultComparer = Rx.internals.isEqual,
47
- inherits = Rx.internals.inherits,
48
- slice = Array.prototype.slice;
49
-
50
- // Utilities
51
- function argsOrArray(args, idx) {
52
- return args.length === 1 && Array.isArray(args[idx]) ?
53
- args[idx] :
54
- slice.call(args);
55
- }
56
-
57
- /** @private */
58
- var Map = (function () {
59
-
60
- /**
61
- * @constructor
62
- * @private
63
- */
64
- function Map() {
65
- this.keys = [];
66
- this.values = [];
67
- }
68
-
69
- /**
70
- * @private
71
- * @memberOf Map#
72
- */
73
- Map.prototype['delete'] = function (key) {
74
- var i = this.keys.indexOf(key);
75
- if (i !== -1) {
76
- this.keys.splice(i, 1);
77
- this.values.splice(i, 1);
78
- }
79
- return i !== -1;
80
- };
81
-
82
- /**
83
- * @private
84
- * @memberOf Map#
85
- */
86
- Map.prototype.get = function (key, fallback) {
87
- var i = this.keys.indexOf(key);
88
- return i !== -1 ? this.values[i] : fallback;
89
- };
90
-
91
- /**
92
- * @private
93
- * @memberOf Map#
94
- */
95
- Map.prototype.set = function (key, value) {
96
- var i = this.keys.indexOf(key);
97
- if (i !== -1) {
98
- this.values[i] = value;
99
- }
100
- this.values[this.keys.push(key) - 1] = value;
101
- };
102
-
103
- /**
104
- * @private
105
- * @memberOf Map#
106
- */
107
- Map.prototype.size = function () { return this.keys.length; };
108
-
109
- /**
110
- * @private
111
- * @memberOf Map#
112
- */
113
- Map.prototype.has = function (key) {
114
- return this.keys.indexOf(key) !== -1;
115
- };
116
-
117
- /**
118
- * @private
119
- * @memberOf Map#
120
- */
121
- Map.prototype.getKeys = function () { return this.keys.slice(0); };
122
-
123
- /**
124
- * @private
125
- * @memberOf Map#
126
- */
127
- Map.prototype.getValues = function () { return this.values.slice(0); };
128
-
129
- return Map;
130
- }());
131
-
132
- /**
133
- * @constructor
134
- * Represents a join pattern over observable sequences.
135
- */
136
- function Pattern(patterns) {
137
- this.patterns = patterns;
34
+
35
+ // Aliases
36
+ var Observable = Rx.Observable,
37
+ observableProto = Observable.prototype,
38
+ AnonymousObservable = Rx.AnonymousObservable,
39
+ observableThrow = Observable.throwException,
40
+ observerCreate = Rx.Observer.create,
41
+ SingleAssignmentDisposable = Rx.SingleAssignmentDisposable,
42
+ CompositeDisposable = Rx.CompositeDisposable,
43
+ AbstractObserver = Rx.internals.AbstractObserver,
44
+ noop = Rx.helpers.noop,
45
+ defaultComparer = Rx.internals.isEqual,
46
+ inherits = Rx.internals.inherits,
47
+ Enumerable = Rx.internals.Enumerable,
48
+ Enumerator = Rx.internals.Enumerator,
49
+ $iterator$ = Rx.iterator,
50
+ doneEnumerator = Rx.doneEnumerator,
51
+ slice = Array.prototype.slice;
52
+
53
+ // Utilities
54
+ function argsOrArray(args, idx) {
55
+ return args.length === 1 && Array.isArray(args[idx]) ?
56
+ args[idx] :
57
+ slice.call(args);
58
+ }
59
+
60
+ /** @private */
61
+ var Map = root.Map || (function () {
62
+
63
+ function Map() {
64
+ this._keys = [];
65
+ this._values = [];
138
66
  }
139
67
 
140
- /**
141
- * Creates a pattern that matches the current plan matches and when the specified observable sequences has an available value.
142
- *
143
- * @param other Observable sequence to match in addition to the current pattern.
144
- * @return Pattern object that matches when all observable sequences in the pattern have an available value.
145
- */
146
- Pattern.prototype.and = function (other) {
147
- var patterns = this.patterns.slice(0);
148
- patterns.push(other);
149
- return new Pattern(patterns);
68
+ Map.prototype.get = function (key) {
69
+ var i = this._keys.indexOf(key);
70
+ return i !== -1 ? this._values[i] : undefined;
71
+ };
72
+
73
+ Map.prototype.set = function (key, value) {
74
+ var i = this._keys.indexOf(key);
75
+ i !== -1 && (this._values[i] = value);
76
+ this._values[this._keys.push(key) - 1] = value;
150
77
  };
151
78
 
152
- /**
153
- * Matches when all observable sequences in the pattern (specified using a chain of and operators) have an available value and projects the values.
154
- *
155
- * @param selector Selector that will be invoked with available values from the source sequences, in the same order of the sequences in the pattern.
156
- * @return Plan that produces the projected values, to be fed (with other plans) to the when operator.
157
- */
158
- Pattern.prototype.thenDo = function (selector) {
159
- return new Plan(this, selector);
79
+ Map.prototype.forEach = function (callback, thisArg) {
80
+ for (var i = 0, len = this._keys.length; i < len; i++) {
81
+ callback.call(thisArg, this._values[i], this._keys[i]);
82
+ }
160
83
  };
161
84
 
162
- function Plan(expression, selector) {
163
- this.expression = expression;
164
- this.selector = selector;
165
- }
166
-
167
- Plan.prototype.activate = function (externalSubscriptions, observer, deactivate) {
168
- var self = this;
169
- var joinObservers = [];
170
- for (var i = 0, len = this.expression.patterns.length; i < len; i++) {
171
- joinObservers.push(planCreateObserver(externalSubscriptions, this.expression.patterns[i], observer.onError.bind(observer)));
172
- }
173
- var activePlan = new ActivePlan(joinObservers, function () {
174
- var result;
175
- try {
176
- result = self.selector.apply(self, arguments);
177
- } catch (exception) {
178
- observer.onError(exception);
179
- return;
180
- }
181
- observer.onNext(result);
182
- }, function () {
183
- for (var j = 0, jlen = joinObservers.length; j < jlen; j++) {
184
- joinObservers[j].removeActivePlan(activePlan);
185
- }
186
- deactivate(activePlan);
187
- });
188
- for (i = 0, len = joinObservers.length; i < len; i++) {
189
- joinObservers[i].addActivePlan(activePlan);
190
- }
191
- return activePlan;
192
- };
193
-
194
- function planCreateObserver(externalSubscriptions, observable, onError) {
195
- var entry = externalSubscriptions.get(observable);
196
- if (!entry) {
197
- var observer = new JoinObserver(observable, onError);
198
- externalSubscriptions.set(observable, observer);
199
- return observer;
200
- }
201
- return entry;
202
- }
203
-
204
- // Active Plan
205
- function ActivePlan(joinObserverArray, onNext, onCompleted) {
206
- var i, joinObserver;
207
- this.joinObserverArray = joinObserverArray;
208
- this.onNext = onNext;
209
- this.onCompleted = onCompleted;
210
- this.joinObservers = new Map();
211
- for (i = 0; i < this.joinObserverArray.length; i++) {
212
- joinObserver = this.joinObserverArray[i];
213
- this.joinObservers.set(joinObserver, joinObserver);
214
- }
215
- }
216
-
217
- ActivePlan.prototype.dequeue = function () {
218
- var values = this.joinObservers.getValues();
219
- for (var i = 0, len = values.length; i < len; i++) {
220
- values[i].queue.shift();
221
- }
222
- };
223
- ActivePlan.prototype.match = function () {
224
- var firstValues, i, len, isCompleted, values, hasValues = true;
225
- for (i = 0, len = this.joinObserverArray.length; i < len; i++) {
226
- if (this.joinObserverArray[i].queue.length === 0) {
227
- hasValues = false;
228
- break;
229
- }
230
- }
231
- if (hasValues) {
232
- firstValues = [];
233
- isCompleted = false;
234
- for (i = 0, len = this.joinObserverArray.length; i < len; i++) {
235
- firstValues.push(this.joinObserverArray[i].queue[0]);
236
- if (this.joinObserverArray[i].queue[0].kind === 'C') {
237
- isCompleted = true;
238
- }
239
- }
240
- if (isCompleted) {
241
- this.onCompleted();
242
- } else {
243
- this.dequeue();
244
- values = [];
245
- for (i = 0; i < firstValues.length; i++) {
246
- values.push(firstValues[i].value);
247
- }
248
- this.onNext.apply(this, values);
249
- }
250
- }
251
- };
252
-
253
- /** @private */
254
- var JoinObserver = (function (_super) {
255
-
256
- inherits(JoinObserver, _super);
257
-
258
- /**
259
- * @constructor
260
- * @private
261
- */
262
- function JoinObserver(source, onError) {
263
- _super.call(this);
264
- this.source = source;
265
- this.onError = onError;
266
- this.queue = [];
267
- this.activePlans = [];
268
- this.subscription = new SingleAssignmentDisposable();
269
- this.isDisposed = false;
270
- }
271
-
272
- var JoinObserverPrototype = JoinObserver.prototype;
273
-
274
- /**
275
- * @memberOf JoinObserver#
276
- * @private
277
- */
278
- JoinObserverPrototype.next = function (notification) {
279
- if (!this.isDisposed) {
280
- if (notification.kind === 'E') {
281
- this.onError(notification.exception);
282
- return;
283
- }
284
- this.queue.push(notification);
285
- var activePlans = this.activePlans.slice(0);
286
- for (var i = 0, len = activePlans.length; i < len; i++) {
287
- activePlans[i].match();
288
- }
289
- }
290
- };
291
-
292
- /**
293
- * @memberOf JoinObserver#
294
- * @private
295
- */
296
- JoinObserverPrototype.error = noop;
297
-
298
- /**
299
- * @memberOf JoinObserver#
300
- * @private
301
- */
302
- JoinObserverPrototype.completed = noop;
303
-
304
- /**
305
- * @memberOf JoinObserver#
306
- * @private
307
- */
308
- JoinObserverPrototype.addActivePlan = function (activePlan) {
309
- this.activePlans.push(activePlan);
310
- };
311
-
312
- /**
313
- * @memberOf JoinObserver#
314
- * @private
315
- */
316
- JoinObserverPrototype.subscribe = function () {
317
- this.subscription.setDisposable(this.source.materialize().subscribe(this));
318
- };
319
-
320
- /**
321
- * @memberOf JoinObserver#
322
- * @private
323
- */
324
- JoinObserverPrototype.removeActivePlan = function (activePlan) {
325
- var idx = this.activePlans.indexOf(activePlan);
326
- this.activePlans.splice(idx, 1);
327
- if (this.activePlans.length === 0) {
328
- this.dispose();
329
- }
330
- };
331
-
332
- /**
333
- * @memberOf JoinObserver#
334
- * @private
335
- */
336
- JoinObserverPrototype.dispose = function () {
337
- _super.prototype.dispose.call(this);
338
- if (!this.isDisposed) {
339
- this.isDisposed = true;
340
- this.subscription.dispose();
341
- }
342
- };
343
-
344
- return JoinObserver;
345
- } (AbstractObserver));
85
+ return Map;
86
+ }());
87
+
88
+ /**
89
+ * @constructor
90
+ * Represents a join pattern over observable sequences.
91
+ */
92
+ function Pattern(patterns) {
93
+ this.patterns = patterns;
94
+ }
95
+
96
+ /**
97
+ * Creates a pattern that matches the current plan matches and when the specified observable sequences has an available value.
98
+ * @param other Observable sequence to match in addition to the current pattern.
99
+ * @return {Pattern} Pattern object that matches when all observable sequences in the pattern have an available value.
100
+ */
101
+ Pattern.prototype.and = function (other) {
102
+ return new Pattern(this.patterns.concat(other));
103
+ };
104
+
105
+ /**
106
+ * Matches when all observable sequences in the pattern (specified using a chain of and operators) have an available value and projects the values.
107
+ * @param {Function} selector Selector that will be invoked with available values from the source sequences, in the same order of the sequences in the pattern.
108
+ * @return {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator.
109
+ */
110
+ Pattern.prototype.thenDo = function (selector) {
111
+ return new Plan(this, selector);
112
+ };
113
+
114
+ function Plan(expression, selector) {
115
+ this.expression = expression;
116
+ this.selector = selector;
117
+ }
118
+
119
+ Plan.prototype.activate = function (externalSubscriptions, observer, deactivate) {
120
+ var self = this;
121
+ var joinObservers = [];
122
+ for (var i = 0, len = this.expression.patterns.length; i < len; i++) {
123
+ joinObservers.push(planCreateObserver(externalSubscriptions, this.expression.patterns[i], observer.onError.bind(observer)));
124
+ }
125
+ var activePlan = new ActivePlan(joinObservers, function () {
126
+ var result;
127
+ try {
128
+ result = self.selector.apply(self, arguments);
129
+ } catch (e) {
130
+ observer.onError(e);
131
+ return;
132
+ }
133
+ observer.onNext(result);
134
+ }, function () {
135
+ for (var j = 0, jlen = joinObservers.length; j < jlen; j++) {
136
+ joinObservers[j].removeActivePlan(activePlan);
137
+ }
138
+ deactivate(activePlan);
139
+ });
140
+ for (i = 0, len = joinObservers.length; i < len; i++) {
141
+ joinObservers[i].addActivePlan(activePlan);
142
+ }
143
+ return activePlan;
144
+ };
145
+
146
+ function planCreateObserver(externalSubscriptions, observable, onError) {
147
+ var entry = externalSubscriptions.get(observable);
148
+ if (!entry) {
149
+ var observer = new JoinObserver(observable, onError);
150
+ externalSubscriptions.set(observable, observer);
151
+ return observer;
152
+ }
153
+ return entry;
154
+ }
155
+
156
+ function ActivePlan(joinObserverArray, onNext, onCompleted) {
157
+ this.joinObserverArray = joinObserverArray;
158
+ this.onNext = onNext;
159
+ this.onCompleted = onCompleted;
160
+ this.joinObservers = new Map();
161
+ for (var i = 0, len = this.joinObserverArray.length; i < len; i++) {
162
+ var joinObserver = this.joinObserverArray[i];
163
+ this.joinObservers.set(joinObserver, joinObserver);
164
+ }
165
+ }
166
+
167
+ ActivePlan.prototype.dequeue = function () {
168
+ this.joinObservers.forEach(function (v) { v.queue.shift(); });
169
+ };
170
+
171
+ ActivePlan.prototype.match = function () {
172
+ var i, len, hasValues = true;
173
+ for (i = 0, len = this.joinObserverArray.length; i < len; i++) {
174
+ if (this.joinObserverArray[i].queue.length === 0) {
175
+ hasValues = false;
176
+ break;
177
+ }
178
+ }
179
+ if (hasValues) {
180
+ var firstValues = [],
181
+ isCompleted = false;
182
+ for (i = 0, len = this.joinObserverArray.length; i < len; i++) {
183
+ firstValues.push(this.joinObserverArray[i].queue[0]);
184
+ this.joinObserverArray[i].queue[0].kind === 'C' && (isCompleted = true);
185
+ }
186
+ if (isCompleted) {
187
+ this.onCompleted();
188
+ } else {
189
+ this.dequeue();
190
+ var values = [];
191
+ for (i = 0, len = firstValues.length; i < firstValues.length; i++) {
192
+ values.push(firstValues[i].value);
193
+ }
194
+ this.onNext.apply(this, values);
195
+ }
196
+ }
197
+ };
198
+
199
+ var JoinObserver = (function (__super__) {
200
+
201
+ inherits(JoinObserver, __super__);
202
+
203
+ function JoinObserver(source, onError) {
204
+ __super__.call(this);
205
+ this.source = source;
206
+ this.onError = onError;
207
+ this.queue = [];
208
+ this.activePlans = [];
209
+ this.subscription = new SingleAssignmentDisposable();
210
+ this.isDisposed = false;
211
+ }
212
+
213
+ var JoinObserverPrototype = JoinObserver.prototype;
214
+
215
+ JoinObserverPrototype.next = function (notification) {
216
+ if (!this.isDisposed) {
217
+ if (notification.kind === 'E') {
218
+ this.onError(notification.exception);
219
+ return;
220
+ }
221
+ this.queue.push(notification);
222
+ var activePlans = this.activePlans.slice(0);
223
+ for (var i = 0, len = activePlans.length; i < len; i++) {
224
+ activePlans[i].match();
225
+ }
226
+ }
227
+ };
228
+
229
+ JoinObserverPrototype.error = noop;
230
+ JoinObserverPrototype.completed = noop;
231
+
232
+ JoinObserverPrototype.addActivePlan = function (activePlan) {
233
+ this.activePlans.push(activePlan);
234
+ };
235
+
236
+ JoinObserverPrototype.subscribe = function () {
237
+ this.subscription.setDisposable(this.source.materialize().subscribe(this));
238
+ };
239
+
240
+ JoinObserverPrototype.removeActivePlan = function (activePlan) {
241
+ this.activePlans.splice(this.activePlans.indexOf(activePlan), 1);
242
+ this.activePlans.length === 0 && this.dispose();
243
+ };
244
+
245
+ JoinObserverPrototype.dispose = function () {
246
+ __super__.prototype.dispose.call(this);
247
+ if (!this.isDisposed) {
248
+ this.isDisposed = true;
249
+ this.subscription.dispose();
250
+ }
251
+ };
252
+
253
+ return JoinObserver;
254
+ } (AbstractObserver));
346
255
 
347
256
  /**
348
257
  * Creates a pattern that matches when both observable sequences have an available value.
349
- *
258
+ *
350
259
  * @param right Observable sequence to match with the current sequence.
351
- * @return {Pattern} Pattern object that matches when both observable sequences have an available value.
260
+ * @return {Pattern} Pattern object that matches when both observable sequences have an available value.
352
261
  */
353
262
  observableProto.and = function (right) {
354
263
  return new Pattern([this, right]);
@@ -356,60 +265,53 @@
356
265
 
357
266
  /**
358
267
  * Matches when the observable sequence has an available value and projects the value.
359
- *
268
+ *
360
269
  * @param selector Selector that will be invoked for values in the source sequence.
361
- * @returns {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator.
362
- */
270
+ * @returns {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator.
271
+ */
363
272
  observableProto.thenDo = function (selector) {
364
273
  return new Pattern([this]).thenDo(selector);
365
274
  };
366
275
 
367
- /**
368
- * Joins together the results from several patterns.
369
- *
370
- * @param plans A series of plans (specified as an Array of as a series of arguments) created by use of the Then operator on patterns.
371
- * @returns {Observable} Observable sequence with the results form matching several patterns.
372
- */
373
- Observable.when = function () {
374
- var plans = argsOrArray(arguments, 0);
375
- return new AnonymousObservable(function (observer) {
376
- var activePlans = [],
377
- externalSubscriptions = new Map(),
378
- group,
379
- i, len,
380
- joinObserver,
381
- joinValues,
382
- outObserver;
383
- outObserver = observerCreate(observer.onNext.bind(observer), function (exception) {
384
- var values = externalSubscriptions.getValues();
385
- for (var j = 0, jlen = values.length; j < jlen; j++) {
386
- values[j].onError(exception);
387
- }
388
- observer.onError(exception);
389
- }, observer.onCompleted.bind(observer));
390
- try {
391
- for (i = 0, len = plans.length; i < len; i++) {
392
- activePlans.push(plans[i].activate(externalSubscriptions, outObserver, function (activePlan) {
393
- var idx = activePlans.indexOf(activePlan);
394
- activePlans.splice(idx, 1);
395
- if (activePlans.length === 0) {
396
- outObserver.onCompleted();
397
- }
398
- }));
399
- }
400
- } catch (e) {
401
- observableThrow(e).subscribe(observer);
402
- }
403
- group = new CompositeDisposable();
404
- joinValues = externalSubscriptions.getValues();
405
- for (i = 0, len = joinValues.length; i < len; i++) {
406
- joinObserver = joinValues[i];
407
- joinObserver.subscribe();
408
- group.add(joinObserver);
409
- }
410
- return group;
411
- });
412
- };
276
+ /**
277
+ * Joins together the results from several patterns.
278
+ *
279
+ * @param plans A series of plans (specified as an Array of as a series of arguments) created by use of the Then operator on patterns.
280
+ * @returns {Observable} Observable sequence with the results form matching several patterns.
281
+ */
282
+ Observable.when = function () {
283
+ var plans = argsOrArray(arguments, 0);
284
+ return new AnonymousObservable(function (observer) {
285
+ var activePlans = [],
286
+ externalSubscriptions = new Map();
287
+ var outObserver = observerCreate(
288
+ observer.onNext.bind(observer),
289
+ function (err) {
290
+ externalSubscriptions.forEach(function (v) { v.onError(err); });
291
+ observer.onError(err);
292
+ },
293
+ observer.onCompleted.bind(observer)
294
+ );
295
+ try {
296
+ for (var i = 0, len = plans.length; i < len; i++) {
297
+ activePlans.push(plans[i].activate(externalSubscriptions, outObserver, function (activePlan) {
298
+ var idx = activePlans.indexOf(activePlan);
299
+ activePlans.splice(idx, 1);
300
+ activePlans.length === 0 && observer.onCompleted();
301
+ }));
302
+ }
303
+ } catch (e) {
304
+ observableThrow(e).subscribe(observer);
305
+ }
306
+ var group = new CompositeDisposable();
307
+ externalSubscriptions.forEach(function (joinObserver) {
308
+ joinObserver.subscribe();
309
+ group.add(joinObserver);
310
+ });
311
+
312
+ return group;
313
+ });
314
+ };
413
315
 
414
- return Rx;
415
- }));
316
+ return Rx;
317
+ }));