rxjs-rails 2.2.19 → 2.2.20

Sign up to get free protection for your applications and to get access to all the features.
@@ -54,7 +54,9 @@
54
54
  Observer = Rx.Observer,
55
55
  inherits = Rx.internals.inherits,
56
56
  addProperties = Rx.internals.addProperties,
57
- noop = Rx.helpers.noop;
57
+ noop = Rx.helpers.noop,
58
+ isPromise = Rx.helpers.isPromise,
59
+ observableFromPromise = Observable.fromPromise;
58
60
 
59
61
  // Utilities
60
62
  function argsOrArray(args, idx) {
@@ -95,28 +97,30 @@
95
97
  return func(this);
96
98
  };
97
99
 
98
- /**
99
- * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers <IE9
100
- *
101
- * @example
102
- * 1 - res = Rx.Observable.if(condition, obs1);
103
- * 2 - res = Rx.Observable.if(condition, obs1, obs2);
104
- * 3 - res = Rx.Observable.if(condition, obs1, scheduler);
105
- * @param {Function} condition The condition which determines if the thenSource or elseSource will be run.
106
- * @param {Observable} thenSource The observable sequence that will be run if the condition function returns true.
107
- * @param {Observable} [elseSource] The observable sequence that will be run if the condition function returns false. If this is not provided, it defaults to Rx.Observabe.Empty with the specified scheduler.
108
- * @returns {Observable} An observable sequence which is either the thenSource or elseSource.
109
- */
110
- Observable['if'] = Observable.ifThen = function (condition, thenSource, elseSourceOrScheduler) {
111
- return observableDefer(function () {
112
- elseSourceOrScheduler || (elseSourceOrScheduler = observableEmpty());
113
- if (elseSourceOrScheduler.now) {
114
- var scheduler = elseSourceOrScheduler;
115
- elseSourceOrScheduler = observableEmpty(scheduler);
116
- }
117
- return condition() ? thenSource : elseSourceOrScheduler;
118
- });
119
- };
100
+ /**
101
+ * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers <IE9
102
+ *
103
+ * @example
104
+ * 1 - res = Rx.Observable.if(condition, obs1);
105
+ * 2 - res = Rx.Observable.if(condition, obs1, obs2);
106
+ * 3 - res = Rx.Observable.if(condition, obs1, scheduler);
107
+ * @param {Function} condition The condition which determines if the thenSource or elseSource will be run.
108
+ * @param {Observable} thenSource The observable sequence or Promise that will be run if the condition function returns true.
109
+ * @param {Observable} [elseSource] The observable sequence or Promise that will be run if the condition function returns false. If this is not provided, it defaults to Rx.Observabe.Empty with the specified scheduler.
110
+ * @returns {Observable} An observable sequence which is either the thenSource or elseSource.
111
+ */
112
+ Observable['if'] = Observable.ifThen = function (condition, thenSource, elseSourceOrScheduler) {
113
+ return observableDefer(function () {
114
+ elseSourceOrScheduler || (elseSourceOrScheduler = observableEmpty());
115
+
116
+ isPromise(thenSource) && (thenSource = observableFromPromise(thenSource));
117
+ isPromise(elseSourceOrScheduler) && (elseSourceOrScheduler = observableFromPromise(elseSourceOrScheduler));
118
+
119
+ // Assume a scheduler for empty only
120
+ typeof elseSourceOrScheduler.now === 'function' && (elseSourceOrScheduler = observableEmpty(elseSourceOrScheduler));
121
+ return condition() ? thenSource : elseSourceOrScheduler;
122
+ });
123
+ };
120
124
 
121
125
  /**
122
126
  * Concatenates the observable sequences obtained by running the specified result selector for each element in source.
@@ -129,17 +133,18 @@
129
133
  return enumerableForEach(sources, resultSelector).concat();
130
134
  };
131
135
 
132
- /**
133
- * Repeats source as long as condition holds emulating a while loop.
134
- * There is an alias for this method called 'whileDo' for browsers <IE9
135
- *
136
- * @param {Function} condition The condition which determines if the source will be repeated.
137
- * @param {Observable} source The observable sequence that will be run if the condition function returns true.
138
- * @returns {Observable} An observable sequence which is repeated as long as the condition holds.
139
- */
140
- var observableWhileDo = Observable['while'] = Observable.whileDo = function (condition, source) {
141
- return enumerableWhile(condition, source).concat();
142
- };
136
+ /**
137
+ * Repeats source as long as condition holds emulating a while loop.
138
+ * There is an alias for this method called 'whileDo' for browsers <IE9
139
+ *
140
+ * @param {Function} condition The condition which determines if the source will be repeated.
141
+ * @param {Observable} source The observable sequence that will be run if the condition function returns true.
142
+ * @returns {Observable} An observable sequence which is repeated as long as the condition holds.
143
+ */
144
+ var observableWhileDo = Observable['while'] = Observable.whileDo = function (condition, source) {
145
+ isPromise(source) && (source = observableFromPromise(source));
146
+ return enumerableWhile(condition, source).concat();
147
+ };
143
148
 
144
149
  /**
145
150
  * Repeats source as long as condition holds emulating a do while loop.
@@ -152,32 +157,33 @@
152
157
  return observableConcat([this, observableWhileDo(condition, this)]);
153
158
  };
154
159
 
155
- /**
156
- * Uses selector to determine which source in sources to use.
157
- * There is an alias 'switchCase' for browsers <IE9.
158
- *
159
- * @example
160
- * 1 - res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 });
161
- * 1 - res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, obs0);
162
- * 1 - res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, scheduler);
163
- *
164
- * @param {Function} selector The function which extracts the value for to test in a case statement.
165
- * @param {Array} sources A object which has keys which correspond to the case statement labels.
166
- * @param {Observable} [elseSource] The observable sequence that will be run if the sources are not matched. If this is not provided, it defaults to Rx.Observabe.Empty with the specified scheduler.
167
- *
168
- * @returns {Observable} An observable sequence which is determined by a case statement.
169
- */
170
- Observable['case'] = Observable.switchCase = function (selector, sources, defaultSourceOrScheduler) {
171
- return observableDefer(function () {
172
- defaultSourceOrScheduler || (defaultSourceOrScheduler = observableEmpty());
173
- if (defaultSourceOrScheduler.now) {
174
- var scheduler = defaultSourceOrScheduler;
175
- defaultSourceOrScheduler = observableEmpty(scheduler);
176
- }
177
- var result = sources[selector()];
178
- return result !== undefined ? result : defaultSourceOrScheduler;
179
- });
180
- };
160
+ /**
161
+ * Uses selector to determine which source in sources to use.
162
+ * There is an alias 'switchCase' for browsers <IE9.
163
+ *
164
+ * @example
165
+ * 1 - res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 });
166
+ * 1 - res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, obs0);
167
+ * 1 - res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, scheduler);
168
+ *
169
+ * @param {Function} selector The function which extracts the value for to test in a case statement.
170
+ * @param {Array} sources A object which has keys which correspond to the case statement labels.
171
+ * @param {Observable} [elseSource] The observable sequence or Promise that will be run if the sources are not matched. If this is not provided, it defaults to Rx.Observabe.empty with the specified scheduler.
172
+ *
173
+ * @returns {Observable} An observable sequence which is determined by a case statement.
174
+ */
175
+ Observable['case'] = Observable.switchCase = function (selector, sources, defaultSourceOrScheduler) {
176
+ return observableDefer(function () {
177
+ defaultSourceOrScheduler || (defaultSourceOrScheduler = observableEmpty());
178
+
179
+ typeof defaultSourceOrScheduler.now === 'function' && (defaultSourceOrScheduler = observableEmpty(defaultSourceOrScheduler));
180
+
181
+ var result = sources[selector()];
182
+ isPromise(result) && (result = observableFromPromise(result));
183
+
184
+ return result || defaultSourceOrScheduler;
185
+ });
186
+ };
181
187
 
182
188
  /**
183
189
  * Expands an observable sequence by recursively invoking selector.
@@ -243,141 +249,146 @@
243
249
  });
244
250
  };
245
251
 
246
- /**
247
- * Runs all observable sequences in parallel and collect their last elements.
248
- *
249
- * @example
250
- * 1 - res = Rx.Observable.forkJoin([obs1, obs2]);
251
- * 1 - res = Rx.Observable.forkJoin(obs1, obs2, ...);
252
- * @returns {Observable} An observable sequence with an array collecting the last elements of all the input sequences.
253
- */
254
- Observable.forkJoin = function () {
255
- var allSources = argsOrArray(arguments, 0);
256
- return new AnonymousObservable(function (subscriber) {
257
- var count = allSources.length;
258
- if (count === 0) {
252
+ /**
253
+ * Runs all observable sequences in parallel and collect their last elements.
254
+ *
255
+ * @example
256
+ * 1 - res = Rx.Observable.forkJoin([obs1, obs2]);
257
+ * 1 - res = Rx.Observable.forkJoin(obs1, obs2, ...);
258
+ * @returns {Observable} An observable sequence with an array collecting the last elements of all the input sequences.
259
+ */
260
+ Observable.forkJoin = function () {
261
+ var allSources = argsOrArray(arguments, 0);
262
+ return new AnonymousObservable(function (subscriber) {
263
+ var count = allSources.length;
264
+ if (count === 0) {
265
+ subscriber.onCompleted();
266
+ return disposableEmpty;
267
+ }
268
+ var group = new CompositeDisposable(),
269
+ finished = false,
270
+ hasResults = new Array(count),
271
+ hasCompleted = new Array(count),
272
+ results = new Array(count);
273
+
274
+ for (var idx = 0; idx < count; idx++) {
275
+ (function (i) {
276
+ var source = allSources[i];
277
+ isPromise(source) && (source = observableFromPromise(source));
278
+ group.add(
279
+ source.subscribe(
280
+ function (value) {
281
+ if (!finished) {
282
+ hasResults[i] = true;
283
+ results[i] = value;
284
+ }
285
+ },
286
+ function (e) {
287
+ finished = true;
288
+ subscriber.onError(e);
289
+ group.dispose();
290
+ },
291
+ function () {
292
+ if (!finished) {
293
+ if (!hasResults[i]) {
294
+ subscriber.onCompleted();
295
+ return;
296
+ }
297
+ hasCompleted[i] = true;
298
+ for (var ix = 0; ix < count; ix++) {
299
+ if (!hasCompleted[ix]) { return; }
300
+ }
301
+ finished = true;
302
+ subscriber.onNext(results);
259
303
  subscriber.onCompleted();
260
- return disposableEmpty;
304
+ }
305
+ }));
306
+ })(idx);
307
+ }
308
+
309
+ return group;
310
+ });
311
+ };
312
+
313
+ /**
314
+ * Runs two observable sequences in parallel and combines their last elemenets.
315
+ *
316
+ * @param {Observable} second Second observable sequence.
317
+ * @param {Function} resultSelector Result selector function to invoke with the last elements of both sequences.
318
+ * @returns {Observable} An observable sequence with the result of calling the selector function with the last elements of both input sequences.
319
+ */
320
+ observableProto.forkJoin = function (second, resultSelector) {
321
+ var first = this;
322
+
323
+ return new AnonymousObservable(function (observer) {
324
+ var leftStopped = false, rightStopped = false,
325
+ hasLeft = false, hasRight = false,
326
+ lastLeft, lastRight,
327
+ leftSubscription = new SingleAssignmentDisposable(), rightSubscription = new SingleAssignmentDisposable();
328
+
329
+ isPromise(second) && (second = observableFromPromise(second));
330
+
331
+ leftSubscription.setDisposable(
332
+ first.subscribe(function (left) {
333
+ hasLeft = true;
334
+ lastLeft = left;
335
+ }, function (err) {
336
+ rightSubscription.dispose();
337
+ observer.onError(err);
338
+ }, function () {
339
+ leftStopped = true;
340
+ if (rightStopped) {
341
+ if (!hasLeft) {
342
+ observer.onCompleted();
343
+ } else if (!hasRight) {
344
+ observer.onCompleted();
345
+ } else {
346
+ var result;
347
+ try {
348
+ result = resultSelector(lastLeft, lastRight);
349
+ } catch (e) {
350
+ observer.onError(e);
351
+ return;
352
+ }
353
+ observer.onNext(result);
354
+ observer.onCompleted();
355
+ }
261
356
  }
262
- var group = new CompositeDisposable(),
263
- finished = false,
264
- hasResults = new Array(count),
265
- hasCompleted = new Array(count),
266
- results = new Array(count);
267
-
268
- for (var idx = 0; idx < count; idx++) {
269
- (function (i) {
270
- var source = allSources[i];
271
- group.add(source.subscribe(function (value) {
272
- if (!finished) {
273
- hasResults[i] = true;
274
- results[i] = value;
275
- }
276
- }, function (e) {
277
- finished = true;
278
- subscriber.onError(e);
279
- group.dispose();
280
- }, function () {
281
- if (!finished) {
282
- if (!hasResults[i]) {
283
- subscriber.onCompleted();
284
- return;
285
- }
286
- hasCompleted[i] = true;
287
- for (var ix = 0; ix < count; ix++) {
288
- if (!hasCompleted[ix]) {
289
- return;
290
- }
291
- }
292
- finished = true;
293
- subscriber.onNext(results);
294
- subscriber.onCompleted();
295
- }
296
- }));
297
- })(idx);
357
+ })
358
+ );
359
+
360
+ rightSubscription.setDisposable(
361
+ second.subscribe(function (right) {
362
+ hasRight = true;
363
+ lastRight = right;
364
+ }, function (err) {
365
+ leftSubscription.dispose();
366
+ observer.onError(err);
367
+ }, function () {
368
+ rightStopped = true;
369
+ if (leftStopped) {
370
+ if (!hasLeft) {
371
+ observer.onCompleted();
372
+ } else if (!hasRight) {
373
+ observer.onCompleted();
374
+ } else {
375
+ var result;
376
+ try {
377
+ result = resultSelector(lastLeft, lastRight);
378
+ } catch (e) {
379
+ observer.onError(e);
380
+ return;
381
+ }
382
+ observer.onNext(result);
383
+ observer.onCompleted();
298
384
  }
385
+ }
386
+ })
387
+ );
299
388
 
300
- return group;
301
- });
302
- };
303
-
304
- /**
305
- * Runs two observable sequences in parallel and combines their last elemenets.
306
- *
307
- * @param {Observable} second Second observable sequence.
308
- * @param {Function} resultSelector Result selector function to invoke with the last elements of both sequences.
309
- * @returns {Observable} An observable sequence with the result of calling the selector function with the last elements of both input sequences.
310
- */
311
- observableProto.forkJoin = function (second, resultSelector) {
312
- var first = this;
313
-
314
- return new AnonymousObservable(function (observer) {
315
- var leftStopped = false, rightStopped = false,
316
- hasLeft = false, hasRight = false,
317
- lastLeft, lastRight,
318
- leftSubscription = new SingleAssignmentDisposable(), rightSubscription = new SingleAssignmentDisposable();
319
-
320
- leftSubscription.setDisposable(
321
- first.subscribe(function (left) {
322
- hasLeft = true;
323
- lastLeft = left;
324
- }, function (err) {
325
- rightSubscription.dispose();
326
- observer.onError(err);
327
- }, function () {
328
- leftStopped = true;
329
- if (rightStopped) {
330
- if (!hasLeft) {
331
- observer.onCompleted();
332
- } else if (!hasRight) {
333
- observer.onCompleted();
334
- } else {
335
- var result;
336
- try {
337
- result = resultSelector(lastLeft, lastRight);
338
- } catch (e) {
339
- observer.onError(e);
340
- return;
341
- }
342
- observer.onNext(result);
343
- observer.onCompleted();
344
- }
345
- }
346
- })
347
- );
348
-
349
- rightSubscription.setDisposable(
350
- second.subscribe(function (right) {
351
- hasRight = true;
352
- lastRight = right;
353
- }, function (err) {
354
- leftSubscription.dispose();
355
- observer.onError(err);
356
- }, function () {
357
- rightStopped = true;
358
- if (leftStopped) {
359
- if (!hasLeft) {
360
- observer.onCompleted();
361
- } else if (!hasRight) {
362
- observer.onCompleted();
363
- } else {
364
- var result;
365
- try {
366
- result = resultSelector(lastLeft, lastRight);
367
- } catch (e) {
368
- observer.onError(e);
369
- return;
370
- }
371
- observer.onNext(result);
372
- observer.onCompleted();
373
- }
374
- }
375
- })
376
- );
377
-
378
- return new CompositeDisposable(leftSubscription, rightSubscription);
379
- });
380
- };
389
+ return new CompositeDisposable(leftSubscription, rightSubscription);
390
+ });
391
+ };
381
392
 
382
393
  /**
383
394
  * Comonadic bind operator.
@@ -1 +1 @@
1
- (function(a){var b={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},c=b[typeof window]&&window||this,d=b[typeof exports]&&exports&&!exports.nodeType&&exports,e=b[typeof module]&&module&&!module.nodeType&&module,f=(e&&e.exports===d&&d,b[typeof global]&&global);!f||f.global!==f&&f.window!==f||(c=f),"function"==typeof define&&define.amd?define(["rx","exports"],function(b,d){return c.Rx=a(c,d,b),c.Rx}):"object"==typeof module&&module&&module.exports===d?module.exports=a(c,module.exports,require("./rx")):c.Rx=a(c,{},c.Rx)}).call(this,function(a,b,c,d){function e(a,b){return 1===a.length&&Array.isArray(a[b])?a[b]:v.call(a)}function f(a,b){return new r(function(){return new q(function(){return a()?{done:!1,value:b}:{done:!0,value:d}})})}var g=c.Observable,h=g.prototype,i=c.AnonymousObservable,j=g.concat,k=g.defer,l=g.empty,m=c.Disposable.empty,n=c.CompositeDisposable,o=c.SerialDisposable,p=c.SingleAssignmentDisposable,q=c.internals.Enumerator,r=c.internals.Enumerable,s=r.forEach,t=c.Scheduler.immediate,u=c.Scheduler.currentThread,v=Array.prototype.slice,w=c.AsyncSubject,x=c.Observer,y=c.internals.inherits,z=c.internals.addProperties,A=c.helpers.noop,B="object"==typeof Symbol&&Symbol.iterator||"_es6shim_iterator_";a.Set&&"function"==typeof(new a.Set)["@@iterator"]&&(B="@@iterator");h.letBind=h.let=function(a){return a(this)},g["if"]=g.ifThen=function(a,b,c){return k(function(){if(c||(c=l()),c.now){var d=c;c=l(d)}return a()?b:c})},g["for"]=g.forIn=function(a,b){return s(a,b).concat()};var C=g["while"]=g.whileDo=function(a,b){return f(a,b).concat()};h.doWhile=function(a){return j([this,C(a,this)])},g["case"]=g.switchCase=function(a,b,c){return k(function(){if(c||(c=l()),c.now){var e=c;c=l(e)}var f=b[a()];return f!==d?f:c})},h.expand=function(a,b){b||(b=t);var c=this;return new i(function(d){var e=[],f=new o,g=new n(f),h=0,i=!1,j=function(){var c=!1;e.length>0&&(c=!i,i=!0),c&&f.setDisposable(b.scheduleRecursive(function(b){var c;if(!(e.length>0))return void(i=!1);c=e.shift();var f=new p;g.add(f),f.setDisposable(c.subscribe(function(b){d.onNext(b);var c=null;try{c=a(b)}catch(f){d.onError(f)}e.push(c),h++,j()},d.onError.bind(d),function(){g.remove(f),h--,0===h&&d.onCompleted()})),b()}))};return e.push(c),h++,j(),g})},g.forkJoin=function(){var a=e(arguments,0);return new i(function(b){var c=a.length;if(0===c)return b.onCompleted(),m;for(var d=new n,e=!1,f=new Array(c),g=new Array(c),h=new Array(c),i=0;c>i;i++)!function(i){var j=a[i];d.add(j.subscribe(function(a){e||(f[i]=!0,h[i]=a)},function(a){e=!0,b.onError(a),d.dispose()},function(){if(!e){if(!f[i])return void b.onCompleted();g[i]=!0;for(var a=0;c>a;a++)if(!g[a])return;e=!0,b.onNext(h),b.onCompleted()}}))}(i);return d})},h.forkJoin=function(a,b){var c=this;return new i(function(d){var e,f,g=!1,h=!1,i=!1,j=!1,k=new p,l=new p;return k.setDisposable(c.subscribe(function(a){i=!0,e=a},function(a){l.dispose(),d.onError(a)},function(){if(g=!0,h)if(i)if(j){var a;try{a=b(e,f)}catch(c){return void d.onError(c)}d.onNext(a),d.onCompleted()}else d.onCompleted();else d.onCompleted()})),l.setDisposable(a.subscribe(function(a){j=!0,f=a},function(a){k.dispose(),d.onError(a)},function(){if(h=!0,g)if(i)if(j){var a;try{a=b(e,f)}catch(c){return void d.onError(c)}d.onNext(a),d.onCompleted()}else d.onCompleted();else d.onCompleted()})),new n(k,l)})},h.manySelect=function(a,b){b||(b=t);var c=this;return k(function(){var d;return c.select(function(a){var b=new D(a);return d&&d.onNext(a),d=b,b}).doAction(A,function(a){d&&d.onError(a)},function(){d&&d.onCompleted()}).observeOn(b).select(function(b,c,d){return a(b,c,d)})})};var D=function(a){function b(a){var b=this,c=new n;return c.add(u.schedule(function(){a.onNext(b.head),c.add(b.tail.mergeObservable().subscribe(a))})),c}function c(c){a.call(this,b),this.head=c,this.tail=new w}return y(c,a),z(c.prototype,x,{onCompleted:function(){this.onNext(g.empty())},onError:function(a){this.onNext(g.throwException(a))},onNext:function(a){this.tail.onNext(a),this.tail.onCompleted()}}),c}(g);return c});
1
+ (function(a){var b={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},c=b[typeof window]&&window||this,d=b[typeof exports]&&exports&&!exports.nodeType&&exports,e=b[typeof module]&&module&&!module.nodeType&&module,f=(e&&e.exports===d&&d,b[typeof global]&&global);!f||f.global!==f&&f.window!==f||(c=f),"function"==typeof define&&define.amd?define(["rx","exports"],function(b,d){return c.Rx=a(c,d,b),c.Rx}):"object"==typeof module&&module&&module.exports===d?module.exports=a(c,module.exports,require("./rx")):c.Rx=a(c,{},c.Rx)}).call(this,function(a,b,c,d){function e(a,b){return 1===a.length&&Array.isArray(a[b])?a[b]:v.call(a)}function f(a,b){return new r(function(){return new q(function(){return a()?{done:!1,value:b}:{done:!0,value:d}})})}var g=c.Observable,h=g.prototype,i=c.AnonymousObservable,j=g.concat,k=g.defer,l=g.empty,m=c.Disposable.empty,n=c.CompositeDisposable,o=c.SerialDisposable,p=c.SingleAssignmentDisposable,q=c.internals.Enumerator,r=c.internals.Enumerable,s=r.forEach,t=c.Scheduler.immediate,u=c.Scheduler.currentThread,v=Array.prototype.slice,w=c.AsyncSubject,x=c.Observer,y=c.internals.inherits,z=c.internals.addProperties,A=c.helpers.noop,B=c.helpers.isPromise,C=g.fromPromise,D="object"==typeof Symbol&&Symbol.iterator||"_es6shim_iterator_";a.Set&&"function"==typeof(new a.Set)["@@iterator"]&&(D="@@iterator");h.letBind=h.let=function(a){return a(this)},g["if"]=g.ifThen=function(a,b,c){return k(function(){return c||(c=l()),B(b)&&(b=C(b)),B(c)&&(c=C(c)),"function"==typeof c.now&&(c=l(c)),a()?b:c})},g["for"]=g.forIn=function(a,b){return s(a,b).concat()};var E=g["while"]=g.whileDo=function(a,b){return B(b)&&(b=C(b)),f(a,b).concat()};h.doWhile=function(a){return j([this,E(a,this)])},g["case"]=g.switchCase=function(a,b,c){return k(function(){c||(c=l()),"function"==typeof c.now&&(c=l(c));var d=b[a()];return B(d)&&(d=C(d)),d||c})},h.expand=function(a,b){b||(b=t);var c=this;return new i(function(d){var e=[],f=new o,g=new n(f),h=0,i=!1,j=function(){var c=!1;e.length>0&&(c=!i,i=!0),c&&f.setDisposable(b.scheduleRecursive(function(b){var c;if(!(e.length>0))return void(i=!1);c=e.shift();var f=new p;g.add(f),f.setDisposable(c.subscribe(function(b){d.onNext(b);var c=null;try{c=a(b)}catch(f){d.onError(f)}e.push(c),h++,j()},d.onError.bind(d),function(){g.remove(f),h--,0===h&&d.onCompleted()})),b()}))};return e.push(c),h++,j(),g})},g.forkJoin=function(){var a=e(arguments,0);return new i(function(b){var c=a.length;if(0===c)return b.onCompleted(),m;for(var d=new n,e=!1,f=new Array(c),g=new Array(c),h=new Array(c),i=0;c>i;i++)!function(i){var j=a[i];B(j)&&(j=C(j)),d.add(j.subscribe(function(a){e||(f[i]=!0,h[i]=a)},function(a){e=!0,b.onError(a),d.dispose()},function(){if(!e){if(!f[i])return void b.onCompleted();g[i]=!0;for(var a=0;c>a;a++)if(!g[a])return;e=!0,b.onNext(h),b.onCompleted()}}))}(i);return d})},h.forkJoin=function(a,b){var c=this;return new i(function(d){var e,f,g=!1,h=!1,i=!1,j=!1,k=new p,l=new p;return B(a)&&(a=C(a)),k.setDisposable(c.subscribe(function(a){i=!0,e=a},function(a){l.dispose(),d.onError(a)},function(){if(g=!0,h)if(i)if(j){var a;try{a=b(e,f)}catch(c){return void d.onError(c)}d.onNext(a),d.onCompleted()}else d.onCompleted();else d.onCompleted()})),l.setDisposable(a.subscribe(function(a){j=!0,f=a},function(a){k.dispose(),d.onError(a)},function(){if(h=!0,g)if(i)if(j){var a;try{a=b(e,f)}catch(c){return void d.onError(c)}d.onNext(a),d.onCompleted()}else d.onCompleted();else d.onCompleted()})),new n(k,l)})},h.manySelect=function(a,b){b||(b=t);var c=this;return k(function(){var d;return c.select(function(a){var b=new F(a);return d&&d.onNext(a),d=b,b}).doAction(A,function(a){d&&d.onError(a)},function(){d&&d.onCompleted()}).observeOn(b).select(function(b,c,d){return a(b,c,d)})})};var F=function(a){function b(a){var b=this,c=new n;return c.add(u.schedule(function(){a.onNext(b.head),c.add(b.tail.mergeObservable().subscribe(a))})),c}function c(c){a.call(this,b),this.head=c,this.tail=new w}return y(c,a),z(c.prototype,x,{onCompleted:function(){this.onNext(g.empty())},onError:function(a){this.onNext(g.throwException(a))},onNext:function(a){this.tail.onNext(a),this.tail.onCompleted()}}),c}(g);return c});