rxjs-rails 2.2.20 → 2.2.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rxjs/rails/version.rb +1 -1
  3. data/vendor/assets/javascripts/rx.aggregates.js +38 -20
  4. data/vendor/assets/javascripts/rx.aggregates.min.js +1 -1
  5. data/vendor/assets/javascripts/rx.all.compat.js +9288 -0
  6. data/vendor/assets/javascripts/rx.all.compat.min.js +3 -0
  7. data/vendor/assets/javascripts/rx.all.js +9102 -0
  8. data/vendor/assets/javascripts/rx.all.min.js +3 -0
  9. data/vendor/assets/javascripts/rx.async.compat.js +5 -4
  10. data/vendor/assets/javascripts/rx.async.compat.min.js +1 -1
  11. data/vendor/assets/javascripts/rx.async.js +5 -4
  12. data/vendor/assets/javascripts/rx.async.min.js +1 -1
  13. data/vendor/assets/javascripts/rx.backpressure.js +24 -12
  14. data/vendor/assets/javascripts/rx.backpressure.min.js +1 -1
  15. data/vendor/assets/javascripts/rx.binding.js +85 -85
  16. data/vendor/assets/javascripts/rx.coincidence.js +59 -15
  17. data/vendor/assets/javascripts/rx.coincidence.min.js +1 -1
  18. data/vendor/assets/javascripts/rx.compat.js +809 -742
  19. data/vendor/assets/javascripts/rx.compat.min.js +2 -2
  20. data/vendor/assets/javascripts/rx.core.compat.js +2629 -0
  21. data/vendor/assets/javascripts/rx.core.compat.min.js +1 -0
  22. data/vendor/assets/javascripts/rx.core.js +2511 -0
  23. data/vendor/assets/javascripts/rx.core.min.js +1 -0
  24. data/vendor/assets/javascripts/rx.experimental.js +43 -43
  25. data/vendor/assets/javascripts/rx.joinpatterns.js +281 -281
  26. data/vendor/assets/javascripts/rx.js +792 -725
  27. data/vendor/assets/javascripts/rx.lite.compat.js +890 -758
  28. data/vendor/assets/javascripts/rx.lite.compat.min.js +2 -2
  29. data/vendor/assets/javascripts/rx.lite.extras.js +664 -0
  30. data/vendor/assets/javascripts/rx.lite.extras.min.js +1 -0
  31. data/vendor/assets/javascripts/rx.lite.js +890 -758
  32. data/vendor/assets/javascripts/rx.lite.min.js +2 -2
  33. data/vendor/assets/javascripts/rx.min.js +2 -2
  34. data/vendor/assets/javascripts/rx.testing.js +166 -166
  35. data/vendor/assets/javascripts/rx.testing.min.js +1 -1
  36. data/vendor/assets/javascripts/rx.time.js +132 -131
  37. data/vendor/assets/javascripts/rx.time.min.js +1 -1
  38. data/vendor/assets/javascripts/rx.virtualtime.js +2 -2
  39. metadata +13 -4
  40. data/vendor/assets/javascripts/rx.node.js +0 -142
@@ -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 (undefined) {
4
4
 
@@ -198,7 +198,7 @@
198
198
  }
199
199
 
200
200
  function isFunction(value) {
201
- return typeof value == 'function';
201
+ return typeof value == 'function' || false;
202
202
  }
203
203
 
204
204
  // fallback for older versions of Chrome and Safari
@@ -392,100 +392,100 @@
392
392
  return a;
393
393
  }
394
394
 
395
- // Collections
396
- var IndexedItem = function (id, value) {
397
- this.id = id;
398
- this.value = value;
399
- };
400
-
401
- IndexedItem.prototype.compareTo = function (other) {
402
- var c = this.value.compareTo(other.value);
403
- if (c === 0) {
404
- c = this.id - other.id;
405
- }
406
- return c;
407
- };
408
-
409
- // Priority Queue for Scheduling
410
- var PriorityQueue = Rx.internals.PriorityQueue = function (capacity) {
411
- this.items = new Array(capacity);
412
- this.length = 0;
413
- };
414
-
415
- var priorityProto = PriorityQueue.prototype;
416
- priorityProto.isHigherPriority = function (left, right) {
417
- return this.items[left].compareTo(this.items[right]) < 0;
418
- };
419
-
420
- priorityProto.percolate = function (index) {
421
- if (index >= this.length || index < 0) {
422
- return;
423
- }
424
- var parent = index - 1 >> 1;
425
- if (parent < 0 || parent === index) {
426
- return;
427
- }
428
- if (this.isHigherPriority(index, parent)) {
429
- var temp = this.items[index];
430
- this.items[index] = this.items[parent];
431
- this.items[parent] = temp;
432
- this.percolate(parent);
433
- }
434
- };
435
-
436
- priorityProto.heapify = function (index) {
437
- if (index === undefined) {
438
- index = 0;
439
- }
440
- if (index >= this.length || index < 0) {
441
- return;
442
- }
443
- var left = 2 * index + 1,
444
- right = 2 * index + 2,
445
- first = index;
446
- if (left < this.length && this.isHigherPriority(left, first)) {
447
- first = left;
448
- }
449
- if (right < this.length && this.isHigherPriority(right, first)) {
450
- first = right;
451
- }
452
- if (first !== index) {
453
- var temp = this.items[index];
454
- this.items[index] = this.items[first];
455
- this.items[first] = temp;
456
- this.heapify(first);
457
- }
458
- };
459
-
460
- priorityProto.peek = function () { return this.items[0].value; };
461
-
462
- priorityProto.removeAt = function (index) {
463
- this.items[index] = this.items[--this.length];
464
- delete this.items[this.length];
465
- this.heapify();
466
- };
467
-
468
- priorityProto.dequeue = function () {
469
- var result = this.peek();
470
- this.removeAt(0);
471
- return result;
472
- };
473
-
474
- priorityProto.enqueue = function (item) {
475
- var index = this.length++;
476
- this.items[index] = new IndexedItem(PriorityQueue.count++, item);
477
- this.percolate(index);
478
- };
479
-
480
- priorityProto.remove = function (item) {
481
- for (var i = 0; i < this.length; i++) {
482
- if (this.items[i].value === item) {
483
- this.removeAt(i);
484
- return true;
485
- }
486
- }
487
- return false;
488
- };
395
+ // Collections
396
+ var IndexedItem = function (id, value) {
397
+ this.id = id;
398
+ this.value = value;
399
+ };
400
+
401
+ IndexedItem.prototype.compareTo = function (other) {
402
+ var c = this.value.compareTo(other.value);
403
+ if (c === 0) {
404
+ c = this.id - other.id;
405
+ }
406
+ return c;
407
+ };
408
+
409
+ // Priority Queue for Scheduling
410
+ var PriorityQueue = Rx.internals.PriorityQueue = function (capacity) {
411
+ this.items = new Array(capacity);
412
+ this.length = 0;
413
+ };
414
+
415
+ var priorityProto = PriorityQueue.prototype;
416
+ priorityProto.isHigherPriority = function (left, right) {
417
+ return this.items[left].compareTo(this.items[right]) < 0;
418
+ };
419
+
420
+ priorityProto.percolate = function (index) {
421
+ if (index >= this.length || index < 0) {
422
+ return;
423
+ }
424
+ var parent = index - 1 >> 1;
425
+ if (parent < 0 || parent === index) {
426
+ return;
427
+ }
428
+ if (this.isHigherPriority(index, parent)) {
429
+ var temp = this.items[index];
430
+ this.items[index] = this.items[parent];
431
+ this.items[parent] = temp;
432
+ this.percolate(parent);
433
+ }
434
+ };
435
+
436
+ priorityProto.heapify = function (index) {
437
+ if (index === undefined) {
438
+ index = 0;
439
+ }
440
+ if (index >= this.length || index < 0) {
441
+ return;
442
+ }
443
+ var left = 2 * index + 1,
444
+ right = 2 * index + 2,
445
+ first = index;
446
+ if (left < this.length && this.isHigherPriority(left, first)) {
447
+ first = left;
448
+ }
449
+ if (right < this.length && this.isHigherPriority(right, first)) {
450
+ first = right;
451
+ }
452
+ if (first !== index) {
453
+ var temp = this.items[index];
454
+ this.items[index] = this.items[first];
455
+ this.items[first] = temp;
456
+ this.heapify(first);
457
+ }
458
+ };
459
+
460
+ priorityProto.peek = function () { return this.items[0].value; };
461
+
462
+ priorityProto.removeAt = function (index) {
463
+ this.items[index] = this.items[--this.length];
464
+ delete this.items[this.length];
465
+ this.heapify();
466
+ };
467
+
468
+ priorityProto.dequeue = function () {
469
+ var result = this.peek();
470
+ this.removeAt(0);
471
+ return result;
472
+ };
473
+
474
+ priorityProto.enqueue = function (item) {
475
+ var index = this.length++;
476
+ this.items[index] = new IndexedItem(PriorityQueue.count++, item);
477
+ this.percolate(index);
478
+ };
479
+
480
+ priorityProto.remove = function (item) {
481
+ for (var i = 0; i < this.length; i++) {
482
+ if (this.items[i].value === item) {
483
+ this.removeAt(i);
484
+ return true;
485
+ }
486
+ }
487
+ return false;
488
+ };
489
489
  PriorityQueue.count = 0;
490
490
  /**
491
491
  * Represents a group of disposable resources that are disposed together.
@@ -754,46 +754,46 @@
754
754
  return RefCountDisposable;
755
755
  })();
756
756
 
757
- function ScheduledDisposable(scheduler, disposable) {
758
- this.scheduler = scheduler;
759
- this.disposable = disposable;
760
- this.isDisposed = false;
761
- }
762
-
763
- ScheduledDisposable.prototype.dispose = function () {
764
- var parent = this;
765
- this.scheduler.schedule(function () {
766
- if (!parent.isDisposed) {
767
- parent.isDisposed = true;
768
- parent.disposable.dispose();
769
- }
770
- });
771
- };
772
-
773
- var ScheduledItem = Rx.internals.ScheduledItem = function (scheduler, state, action, dueTime, comparer) {
774
- this.scheduler = scheduler;
775
- this.state = state;
776
- this.action = action;
777
- this.dueTime = dueTime;
778
- this.comparer = comparer || defaultSubComparer;
779
- this.disposable = new SingleAssignmentDisposable();
780
- }
781
-
782
- ScheduledItem.prototype.invoke = function () {
783
- this.disposable.setDisposable(this.invokeCore());
784
- };
785
-
786
- ScheduledItem.prototype.compareTo = function (other) {
787
- return this.comparer(this.dueTime, other.dueTime);
788
- };
789
-
790
- ScheduledItem.prototype.isCancelled = function () {
791
- return this.disposable.isDisposed;
792
- };
793
-
794
- ScheduledItem.prototype.invokeCore = function () {
795
- return this.action(this.scheduler, this.state);
796
- };
757
+ function ScheduledDisposable(scheduler, disposable) {
758
+ this.scheduler = scheduler;
759
+ this.disposable = disposable;
760
+ this.isDisposed = false;
761
+ }
762
+
763
+ ScheduledDisposable.prototype.dispose = function () {
764
+ var parent = this;
765
+ this.scheduler.schedule(function () {
766
+ if (!parent.isDisposed) {
767
+ parent.isDisposed = true;
768
+ parent.disposable.dispose();
769
+ }
770
+ });
771
+ };
772
+
773
+ var ScheduledItem = Rx.internals.ScheduledItem = function (scheduler, state, action, dueTime, comparer) {
774
+ this.scheduler = scheduler;
775
+ this.state = state;
776
+ this.action = action;
777
+ this.dueTime = dueTime;
778
+ this.comparer = comparer || defaultSubComparer;
779
+ this.disposable = new SingleAssignmentDisposable();
780
+ }
781
+
782
+ ScheduledItem.prototype.invoke = function () {
783
+ this.disposable.setDisposable(this.invokeCore());
784
+ };
785
+
786
+ ScheduledItem.prototype.compareTo = function (other) {
787
+ return this.comparer(this.dueTime, other.dueTime);
788
+ };
789
+
790
+ ScheduledItem.prototype.isCancelled = function () {
791
+ return this.disposable.isDisposed;
792
+ };
793
+
794
+ ScheduledItem.prototype.invokeCore = function () {
795
+ return this.action(this.scheduler, this.state);
796
+ };
797
797
 
798
798
  /** Provides a set of static properties to access commonly used schedulers. */
799
799
  var Scheduler = Rx.Scheduler = (function () {
@@ -1061,54 +1061,54 @@
1061
1061
 
1062
1062
  var normalizeTime = Scheduler.normalize;
1063
1063
 
1064
- var SchedulePeriodicRecursive = Rx.internals.SchedulePeriodicRecursive = (function () {
1065
- function tick(command, recurse) {
1066
- recurse(0, this._period);
1067
- try {
1068
- this._state = this._action(this._state);
1069
- } catch (e) {
1070
- this._cancel.dispose();
1071
- throw e;
1072
- }
1073
- }
1074
-
1075
- function SchedulePeriodicRecursive(scheduler, state, period, action) {
1076
- this._scheduler = scheduler;
1077
- this._state = state;
1078
- this._period = period;
1079
- this._action = action;
1080
- }
1081
-
1082
- SchedulePeriodicRecursive.prototype.start = function () {
1083
- var d = new SingleAssignmentDisposable();
1084
- this._cancel = d;
1085
- d.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0, this._period, tick.bind(this)));
1086
-
1087
- return d;
1088
- };
1089
-
1090
- return SchedulePeriodicRecursive;
1091
- }());
1092
-
1093
- /**
1094
- * Gets a scheduler that schedules work immediately on the current thread.
1095
- */
1096
- var immediateScheduler = Scheduler.immediate = (function () {
1097
-
1098
- function scheduleNow(state, action) { return action(this, state); }
1099
-
1100
- function scheduleRelative(state, dueTime, action) {
1101
- var dt = normalizeTime(dt);
1102
- while (dt - this.now() > 0) { }
1103
- return action(this, state);
1104
- }
1105
-
1106
- function scheduleAbsolute(state, dueTime, action) {
1107
- return this.scheduleWithRelativeAndState(state, dueTime - this.now(), action);
1108
- }
1109
-
1110
- return new Scheduler(defaultNow, scheduleNow, scheduleRelative, scheduleAbsolute);
1111
- }());
1064
+ var SchedulePeriodicRecursive = Rx.internals.SchedulePeriodicRecursive = (function () {
1065
+ function tick(command, recurse) {
1066
+ recurse(0, this._period);
1067
+ try {
1068
+ this._state = this._action(this._state);
1069
+ } catch (e) {
1070
+ this._cancel.dispose();
1071
+ throw e;
1072
+ }
1073
+ }
1074
+
1075
+ function SchedulePeriodicRecursive(scheduler, state, period, action) {
1076
+ this._scheduler = scheduler;
1077
+ this._state = state;
1078
+ this._period = period;
1079
+ this._action = action;
1080
+ }
1081
+
1082
+ SchedulePeriodicRecursive.prototype.start = function () {
1083
+ var d = new SingleAssignmentDisposable();
1084
+ this._cancel = d;
1085
+ d.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0, this._period, tick.bind(this)));
1086
+
1087
+ return d;
1088
+ };
1089
+
1090
+ return SchedulePeriodicRecursive;
1091
+ }());
1092
+
1093
+ /**
1094
+ * Gets a scheduler that schedules work immediately on the current thread.
1095
+ */
1096
+ var immediateScheduler = Scheduler.immediate = (function () {
1097
+
1098
+ function scheduleNow(state, action) { return action(this, state); }
1099
+
1100
+ function scheduleRelative(state, dueTime, action) {
1101
+ var dt = normalizeTime(dt);
1102
+ while (dt - this.now() > 0) { }
1103
+ return action(this, state);
1104
+ }
1105
+
1106
+ function scheduleAbsolute(state, dueTime, action) {
1107
+ return this.scheduleWithRelativeAndState(state, dueTime - this.now(), action);
1108
+ }
1109
+
1110
+ return new Scheduler(defaultNow, scheduleNow, scheduleRelative, scheduleAbsolute);
1111
+ }());
1112
1112
 
1113
1113
  /**
1114
1114
  * Gets a scheduler that schedules work as soon as possible on the current thread.
@@ -1527,231 +1527,230 @@
1527
1527
  };
1528
1528
  }());
1529
1529
 
1530
- var Enumerator = Rx.internals.Enumerator = function (next) {
1531
- this._next = next;
1532
- };
1533
-
1534
- Enumerator.prototype.next = function () {
1535
- return this._next();
1536
- };
1537
-
1538
- Enumerator.prototype[$iterator$] = function () { return this; }
1539
-
1540
- var Enumerable = Rx.internals.Enumerable = function (iterator) {
1541
- this._iterator = iterator;
1542
- };
1543
-
1544
- Enumerable.prototype[$iterator$] = function () {
1545
- return this._iterator();
1546
- };
1547
-
1548
- Enumerable.prototype.concat = function () {
1549
- var sources = this;
1550
- return new AnonymousObservable(function (observer) {
1551
- var e;
1552
- try {
1553
- e = sources[$iterator$]();
1554
- } catch(err) {
1555
- observer.onError();
1556
- return;
1557
- }
1558
-
1559
- var isDisposed,
1560
- subscription = new SerialDisposable();
1561
- var cancelable = immediateScheduler.scheduleRecursive(function (self) {
1562
- var currentItem;
1563
- if (isDisposed) { return; }
1564
-
1565
- try {
1566
- currentItem = e.next();
1567
- } catch (ex) {
1568
- observer.onError(ex);
1569
- return;
1570
- }
1571
-
1572
- if (currentItem.done) {
1573
- observer.onCompleted();
1574
- return;
1575
- }
1576
-
1577
- // Check if promise
1578
- var currentValue = currentItem.value;
1579
- isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));
1580
-
1581
- var d = new SingleAssignmentDisposable();
1582
- subscription.setDisposable(d);
1583
- d.setDisposable(currentValue.subscribe(
1584
- observer.onNext.bind(observer),
1585
- observer.onError.bind(observer),
1586
- function () { self(); })
1587
- );
1588
- });
1589
-
1590
- return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {
1591
- isDisposed = true;
1592
- }));
1593
- });
1594
- };
1595
-
1596
- Enumerable.prototype.catchException = function () {
1597
- var sources = this;
1598
- return new AnonymousObservable(function (observer) {
1599
- var e;
1600
- try {
1601
- e = sources[$iterator$]();
1602
- } catch(err) {
1603
- observer.onError();
1604
- return;
1605
- }
1606
-
1607
- var isDisposed,
1608
- lastException,
1609
- subscription = new SerialDisposable();
1610
- var cancelable = immediateScheduler.scheduleRecursive(function (self) {
1611
- if (isDisposed) { return; }
1612
-
1613
- var currentItem;
1614
- try {
1615
- currentItem = e.next();
1616
- } catch (ex) {
1617
- observer.onError(ex);
1618
- return;
1619
- }
1620
-
1621
- if (currentItem.done) {
1622
- if (lastException) {
1623
- observer.onError(lastException);
1624
- } else {
1625
- observer.onCompleted();
1626
- }
1627
- return;
1628
- }
1629
-
1630
- // Check if promise
1631
- var currentValue = currentItem.value;
1632
- isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));
1633
-
1634
- var d = new SingleAssignmentDisposable();
1635
- subscription.setDisposable(d);
1636
- d.setDisposable(currentValue.subscribe(
1637
- observer.onNext.bind(observer),
1638
- function (exn) {
1639
- lastException = exn;
1640
- self();
1641
- },
1642
- observer.onCompleted.bind(observer)));
1643
- });
1644
- return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {
1645
- isDisposed = true;
1646
- }));
1647
- });
1648
- };
1649
-
1650
-
1651
- var enumerableRepeat = Enumerable.repeat = function (value, repeatCount) {
1652
- if (repeatCount == null) { repeatCount = -1; }
1653
- return new Enumerable(function () {
1654
- var left = repeatCount;
1655
- return new Enumerator(function () {
1656
- if (left === 0) { return doneEnumerator; }
1657
- if (left > 0) { left--; }
1658
- return { done: false, value: value };
1659
- });
1660
- });
1661
- };
1662
-
1663
- var enumerableFor = Enumerable.forEach = function (source, selector, thisArg) {
1664
- selector || (selector = identity);
1665
- return new Enumerable(function () {
1666
- var index = -1;
1667
- return new Enumerator(
1668
- function () {
1669
- return ++index < source.length ?
1670
- { done: false, value: selector.call(thisArg, source[index], index, source) } :
1671
- doneEnumerator;
1672
- });
1673
- });
1674
- };
1530
+ var Enumerator = Rx.internals.Enumerator = function (next) {
1531
+ this._next = next;
1532
+ };
1675
1533
 
1676
- /**
1677
- * Supports push-style iteration over an observable sequence.
1678
- */
1679
- var Observer = Rx.Observer = function () { };
1534
+ Enumerator.prototype.next = function () {
1535
+ return this._next();
1536
+ };
1680
1537
 
1681
- /**
1682
- * Creates a notification callback from an observer.
1683
- *
1684
- * @param observer Observer object.
1685
- * @returns The action that forwards its input notification to the underlying observer.
1686
- */
1687
- Observer.prototype.toNotifier = function () {
1688
- var observer = this;
1689
- return function (n) {
1690
- return n.accept(observer);
1691
- };
1692
- };
1538
+ Enumerator.prototype[$iterator$] = function () { return this; }
1693
1539
 
1694
- /**
1695
- * Hides the identity of an observer.
1540
+ var Enumerable = Rx.internals.Enumerable = function (iterator) {
1541
+ this._iterator = iterator;
1542
+ };
1696
1543
 
1697
- * @returns An observer that hides the identity of the specified observer.
1698
- */
1699
- Observer.prototype.asObserver = function () {
1700
- return new AnonymousObserver(this.onNext.bind(this), this.onError.bind(this), this.onCompleted.bind(this));
1701
- };
1544
+ Enumerable.prototype[$iterator$] = function () {
1545
+ return this._iterator();
1546
+ };
1702
1547
 
1703
- /**
1704
- * Checks access to the observer for grammar violations. This includes checking for multiple OnError or OnCompleted calls, as well as reentrancy in any of the observer methods.
1705
- * If a violation is detected, an Error is thrown from the offending observer method call.
1706
- *
1707
- * @returns An observer that checks callbacks invocations against the observer grammar and, if the checks pass, forwards those to the specified observer.
1708
- */
1709
- Observer.prototype.checked = function () { return new CheckedObserver(this); };
1548
+ Enumerable.prototype.concat = function () {
1549
+ var sources = this;
1550
+ return new AnonymousObservable(function (observer) {
1551
+ var e;
1552
+ try {
1553
+ e = sources[$iterator$]();
1554
+ } catch(err) {
1555
+ observer.onError();
1556
+ return;
1557
+ }
1710
1558
 
1711
- /**
1712
- * Creates an observer from the specified OnNext, along with optional OnError, and OnCompleted actions.
1713
- *
1714
- * @static
1715
- * @memberOf Observer
1716
- * @param {Function} [onNext] Observer's OnNext action implementation.
1717
- * @param {Function} [onError] Observer's OnError action implementation.
1718
- * @param {Function} [onCompleted] Observer's OnCompleted action implementation.
1719
- * @returns {Observer} The observer object implemented using the given actions.
1720
- */
1721
- var observerCreate = Observer.create = function (onNext, onError, onCompleted) {
1722
- onNext || (onNext = noop);
1723
- onError || (onError = defaultError);
1724
- onCompleted || (onCompleted = noop);
1725
- return new AnonymousObserver(onNext, onError, onCompleted);
1726
- };
1559
+ var isDisposed,
1560
+ subscription = new SerialDisposable();
1561
+ var cancelable = immediateScheduler.scheduleRecursive(function (self) {
1562
+ var currentItem;
1563
+ if (isDisposed) { return; }
1727
1564
 
1728
- /**
1729
- * Creates an observer from a notification callback.
1730
- *
1731
- * @static
1732
- * @memberOf Observer
1733
- * @param {Function} handler Action that handles a notification.
1734
- * @returns The observer object that invokes the specified handler using a notification corresponding to each message it receives.
1735
- */
1736
- Observer.fromNotifier = function (handler) {
1737
- return new AnonymousObserver(function (x) {
1738
- return handler(notificationCreateOnNext(x));
1739
- }, function (exception) {
1740
- return handler(notificationCreateOnError(exception));
1741
- }, function () {
1742
- return handler(notificationCreateOnCompleted());
1565
+ try {
1566
+ currentItem = e.next();
1567
+ } catch (ex) {
1568
+ observer.onError(ex);
1569
+ return;
1570
+ }
1571
+
1572
+ if (currentItem.done) {
1573
+ observer.onCompleted();
1574
+ return;
1575
+ }
1576
+
1577
+ // Check if promise
1578
+ var currentValue = currentItem.value;
1579
+ isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));
1580
+
1581
+ var d = new SingleAssignmentDisposable();
1582
+ subscription.setDisposable(d);
1583
+ d.setDisposable(currentValue.subscribe(
1584
+ observer.onNext.bind(observer),
1585
+ observer.onError.bind(observer),
1586
+ function () { self(); })
1587
+ );
1588
+ });
1589
+
1590
+ return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {
1591
+ isDisposed = true;
1592
+ }));
1593
+ });
1594
+ };
1595
+
1596
+ Enumerable.prototype.catchException = function () {
1597
+ var sources = this;
1598
+ return new AnonymousObservable(function (observer) {
1599
+ var e;
1600
+ try {
1601
+ e = sources[$iterator$]();
1602
+ } catch(err) {
1603
+ observer.onError();
1604
+ return;
1605
+ }
1606
+
1607
+ var isDisposed,
1608
+ lastException,
1609
+ subscription = new SerialDisposable();
1610
+ var cancelable = immediateScheduler.scheduleRecursive(function (self) {
1611
+ if (isDisposed) { return; }
1612
+
1613
+ var currentItem;
1614
+ try {
1615
+ currentItem = e.next();
1616
+ } catch (ex) {
1617
+ observer.onError(ex);
1618
+ return;
1619
+ }
1620
+
1621
+ if (currentItem.done) {
1622
+ if (lastException) {
1623
+ observer.onError(lastException);
1624
+ } else {
1625
+ observer.onCompleted();
1626
+ }
1627
+ return;
1628
+ }
1629
+
1630
+ // Check if promise
1631
+ var currentValue = currentItem.value;
1632
+ isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));
1633
+
1634
+ var d = new SingleAssignmentDisposable();
1635
+ subscription.setDisposable(d);
1636
+ d.setDisposable(currentValue.subscribe(
1637
+ observer.onNext.bind(observer),
1638
+ function (exn) {
1639
+ lastException = exn;
1640
+ self();
1641
+ },
1642
+ observer.onCompleted.bind(observer)));
1643
+ });
1644
+ return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {
1645
+ isDisposed = true;
1646
+ }));
1647
+ });
1648
+ };
1649
+
1650
+ var enumerableRepeat = Enumerable.repeat = function (value, repeatCount) {
1651
+ if (repeatCount == null) { repeatCount = -1; }
1652
+ return new Enumerable(function () {
1653
+ var left = repeatCount;
1654
+ return new Enumerator(function () {
1655
+ if (left === 0) { return doneEnumerator; }
1656
+ if (left > 0) { left--; }
1657
+ return { done: false, value: value };
1658
+ });
1659
+ });
1660
+ };
1661
+
1662
+ var enumerableFor = Enumerable.forEach = function (source, selector, thisArg) {
1663
+ selector || (selector = identity);
1664
+ return new Enumerable(function () {
1665
+ var index = -1;
1666
+ return new Enumerator(
1667
+ function () {
1668
+ return ++index < source.length ?
1669
+ { done: false, value: selector.call(thisArg, source[index], index, source) } :
1670
+ doneEnumerator;
1743
1671
  });
1744
- };
1672
+ });
1673
+ };
1745
1674
 
1746
- /**
1747
- * Schedules the invocation of observer methods on the given scheduler.
1748
- * @param {Scheduler} scheduler Scheduler to schedule observer messages on.
1749
- * @returns {Observer} Observer whose messages are scheduled on the given scheduler.
1750
- */
1751
- Observer.notifyOn = function (scheduler) {
1752
- return new ObserveOnObserver(scheduler, this);
1675
+ /**
1676
+ * Supports push-style iteration over an observable sequence.
1677
+ */
1678
+ var Observer = Rx.Observer = function () { };
1679
+
1680
+ /**
1681
+ * Creates a notification callback from an observer.
1682
+ *
1683
+ * @param observer Observer object.
1684
+ * @returns The action that forwards its input notification to the underlying observer.
1685
+ */
1686
+ Observer.prototype.toNotifier = function () {
1687
+ var observer = this;
1688
+ return function (n) {
1689
+ return n.accept(observer);
1753
1690
  };
1754
-
1691
+ };
1692
+
1693
+ /**
1694
+ * Hides the identity of an observer.
1695
+
1696
+ * @returns An observer that hides the identity of the specified observer.
1697
+ */
1698
+ Observer.prototype.asObserver = function () {
1699
+ return new AnonymousObserver(this.onNext.bind(this), this.onError.bind(this), this.onCompleted.bind(this));
1700
+ };
1701
+
1702
+ /**
1703
+ * Checks access to the observer for grammar violations. This includes checking for multiple OnError or OnCompleted calls, as well as reentrancy in any of the observer methods.
1704
+ * If a violation is detected, an Error is thrown from the offending observer method call.
1705
+ *
1706
+ * @returns An observer that checks callbacks invocations against the observer grammar and, if the checks pass, forwards those to the specified observer.
1707
+ */
1708
+ Observer.prototype.checked = function () { return new CheckedObserver(this); };
1709
+
1710
+ /**
1711
+ * Creates an observer from the specified OnNext, along with optional OnError, and OnCompleted actions.
1712
+ *
1713
+ * @static
1714
+ * @memberOf Observer
1715
+ * @param {Function} [onNext] Observer's OnNext action implementation.
1716
+ * @param {Function} [onError] Observer's OnError action implementation.
1717
+ * @param {Function} [onCompleted] Observer's OnCompleted action implementation.
1718
+ * @returns {Observer} The observer object implemented using the given actions.
1719
+ */
1720
+ var observerCreate = Observer.create = function (onNext, onError, onCompleted) {
1721
+ onNext || (onNext = noop);
1722
+ onError || (onError = defaultError);
1723
+ onCompleted || (onCompleted = noop);
1724
+ return new AnonymousObserver(onNext, onError, onCompleted);
1725
+ };
1726
+
1727
+ /**
1728
+ * Creates an observer from a notification callback.
1729
+ *
1730
+ * @static
1731
+ * @memberOf Observer
1732
+ * @param {Function} handler Action that handles a notification.
1733
+ * @returns The observer object that invokes the specified handler using a notification corresponding to each message it receives.
1734
+ */
1735
+ Observer.fromNotifier = function (handler) {
1736
+ return new AnonymousObserver(function (x) {
1737
+ return handler(notificationCreateOnNext(x));
1738
+ }, function (exception) {
1739
+ return handler(notificationCreateOnError(exception));
1740
+ }, function () {
1741
+ return handler(notificationCreateOnCompleted());
1742
+ });
1743
+ };
1744
+
1745
+ /**
1746
+ * Schedules the invocation of observer methods on the given scheduler.
1747
+ * @param {Scheduler} scheduler Scheduler to schedule observer messages on.
1748
+ * @returns {Observer} Observer whose messages are scheduled on the given scheduler.
1749
+ */
1750
+ Observer.notifyOn = function (scheduler) {
1751
+ return new ObserveOnObserver(scheduler, this);
1752
+ };
1753
+
1755
1754
  /**
1756
1755
  * Abstract base class for implementations of the Observer class.
1757
1756
  * This base class enforces the grammar of observers where OnError and OnCompleted are terminal messages.
@@ -2021,83 +2020,43 @@
2021
2020
  return ObserveOnObserver;
2022
2021
  })(ScheduledObserver);
2023
2022
 
2024
- var observableProto;
2025
-
2026
- /**
2027
- * Represents a push-style collection.
2028
- */
2029
- var Observable = Rx.Observable = (function () {
2030
-
2031
- /**
2032
- * @constructor
2033
- * @private
2034
- */
2035
- function Observable(subscribe) {
2036
- this._subscribe = subscribe;
2037
- }
2023
+ var observableProto;
2038
2024
 
2039
- observableProto = Observable.prototype;
2025
+ /**
2026
+ * Represents a push-style collection.
2027
+ */
2028
+ var Observable = Rx.Observable = (function () {
2040
2029
 
2041
- observableProto.finalValue = function () {
2042
- var source = this;
2043
- return new AnonymousObservable(function (observer) {
2044
- var hasValue = false, value;
2045
- return source.subscribe(function (x) {
2046
- hasValue = true;
2047
- value = x;
2048
- }, observer.onError.bind(observer), function () {
2049
- if (!hasValue) {
2050
- observer.onError(new Error(sequenceContainsNoElements));
2051
- } else {
2052
- observer.onNext(value);
2053
- observer.onCompleted();
2054
- }
2055
- });
2056
- });
2057
- };
2030
+ function Observable(subscribe) {
2031
+ this._subscribe = subscribe;
2032
+ }
2058
2033
 
2059
- /**
2060
- * Subscribes an observer to the observable sequence.
2061
- *
2062
- * @example
2063
- * 1 - source.subscribe();
2064
- * 2 - source.subscribe(observer);
2065
- * 3 - source.subscribe(function (x) { console.log(x); });
2066
- * 4 - source.subscribe(function (x) { console.log(x); }, function (err) { console.log(err); });
2067
- * 5 - source.subscribe(function (x) { console.log(x); }, function (err) { console.log(err); }, function () { console.log('done'); });
2068
- * @param {Mixed} [observerOrOnNext] The object that is to receive notifications or an action to invoke for each element in the observable sequence.
2069
- * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence.
2070
- * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence.
2071
- * @returns {Diposable} The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler.
2072
- */
2073
- observableProto.subscribe = observableProto.forEach = function (observerOrOnNext, onError, onCompleted) {
2074
- var subscriber;
2075
- if (typeof observerOrOnNext === 'object') {
2076
- subscriber = observerOrOnNext;
2077
- } else {
2078
- subscriber = observerCreate(observerOrOnNext, onError, onCompleted);
2079
- }
2034
+ observableProto = Observable.prototype;
2080
2035
 
2081
- return this._subscribe(subscriber);
2082
- };
2036
+ /**
2037
+ * Subscribes an observer to the observable sequence.
2038
+ *
2039
+ * @example
2040
+ * 1 - source.subscribe();
2041
+ * 2 - source.subscribe(observer);
2042
+ * 3 - source.subscribe(function (x) { console.log(x); });
2043
+ * 4 - source.subscribe(function (x) { console.log(x); }, function (err) { console.log(err); });
2044
+ * 5 - source.subscribe(function (x) { console.log(x); }, function (err) { console.log(err); }, function () { console.log('done'); });
2045
+ * @param {Mixed} [observerOrOnNext] The object that is to receive notifications or an action to invoke for each element in the observable sequence.
2046
+ * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence.
2047
+ * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence.
2048
+ * @returns {Diposable} The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler.
2049
+ */
2050
+ observableProto.subscribe = observableProto.forEach = function (observerOrOnNext, onError, onCompleted) {
2051
+ var subscriber = typeof observerOrOnNext === 'object' ?
2052
+ observerOrOnNext :
2053
+ observerCreate(observerOrOnNext, onError, onCompleted);
2083
2054
 
2084
- /**
2085
- * Creates a list from an observable sequence.
2086
- *
2087
- * @memberOf Observable
2088
- * @returns An observable sequence containing a single element with a list containing all the elements of the source sequence.
2089
- */
2090
- observableProto.toArray = function () {
2091
- function accumulator(list, i) {
2092
- var newList = list.slice(0);
2093
- newList.push(i);
2094
- return newList;
2095
- }
2096
- return this.scan([], accumulator).startWith([]).finalValue();
2097
- };
2055
+ return this._subscribe(subscriber);
2056
+ };
2098
2057
 
2099
- return Observable;
2100
- })();
2058
+ return Observable;
2059
+ })();
2101
2060
 
2102
2061
  /**
2103
2062
  * Wraps the source sequence in order to run its observer callbacks on the specified scheduler.
@@ -2192,6 +2151,24 @@
2192
2151
  });
2193
2152
  });
2194
2153
  };
2154
+ /**
2155
+ * Creates a list from an observable sequence.
2156
+ * @returns An observable sequence containing a single element with a list containing all the elements of the source sequence.
2157
+ */
2158
+ observableProto.toArray = function () {
2159
+ var self = this;
2160
+ return new AnonymousObservable(function(observer) {
2161
+ var arr = [];
2162
+ return self.subscribe(
2163
+ arr.push.bind(arr),
2164
+ observer.onError.bind(observer),
2165
+ function () {
2166
+ observer.onNext(arr);
2167
+ observer.onCompleted();
2168
+ });
2169
+ });
2170
+ };
2171
+
2195
2172
  /**
2196
2173
  * Creates an observable sequence from a specified subscribe method implementation.
2197
2174
  *
@@ -2449,30 +2426,30 @@
2449
2426
  });
2450
2427
  };
2451
2428
 
2452
- /**
2453
- * Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence's lifetime.
2454
- *
2455
- * @example
2456
- * var res = Rx.Observable.using(function () { return new AsyncSubject(); }, function (s) { return s; });
2457
- * @param {Function} resourceFactory Factory function to obtain a resource object.
2458
- * @param {Function} observableFactory Factory function to obtain an observable sequence that depends on the obtained resource.
2459
- * @returns {Observable} An observable sequence whose lifetime controls the lifetime of the dependent resource object.
2460
- */
2461
- Observable.using = function (resourceFactory, observableFactory) {
2462
- return new AnonymousObservable(function (observer) {
2463
- var disposable = disposableEmpty, resource, source;
2464
- try {
2465
- resource = resourceFactory();
2466
- if (resource) {
2467
- disposable = resource;
2468
- }
2469
- source = observableFactory(resource);
2470
- } catch (exception) {
2471
- return new CompositeDisposable(observableThrow(exception).subscribe(observer), disposable);
2472
- }
2473
- return new CompositeDisposable(source.subscribe(observer), disposable);
2474
- });
2475
- };
2429
+ /**
2430
+ * Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence's lifetime.
2431
+ *
2432
+ * @example
2433
+ * var res = Rx.Observable.using(function () { return new AsyncSubject(); }, function (s) { return s; });
2434
+ * @param {Function} resourceFactory Factory function to obtain a resource object.
2435
+ * @param {Function} observableFactory Factory function to obtain an observable sequence that depends on the obtained resource.
2436
+ * @returns {Observable} An observable sequence whose lifetime controls the lifetime of the dependent resource object.
2437
+ */
2438
+ Observable.using = function (resourceFactory, observableFactory) {
2439
+ return new AnonymousObservable(function (observer) {
2440
+ var disposable = disposableEmpty, resource, source;
2441
+ try {
2442
+ resource = resourceFactory();
2443
+ if (resource) {
2444
+ disposable = resource;
2445
+ }
2446
+ source = observableFactory(resource);
2447
+ } catch (exception) {
2448
+ return new CompositeDisposable(observableThrow(exception).subscribe(observer), disposable);
2449
+ }
2450
+ return new CompositeDisposable(source.subscribe(observer), disposable);
2451
+ });
2452
+ };
2476
2453
 
2477
2454
  /**
2478
2455
  * Propagates the observable sequence or Promise that reacts first.
@@ -2895,37 +2872,35 @@
2895
2872
  });
2896
2873
  };
2897
2874
 
2898
- /**
2899
- * Returns the values from the source observable sequence only after the other observable sequence produces a value.
2900
- * @param {Observable} other The observable sequence that triggers propagation of elements of the source sequence.
2901
- * @returns {Observable} An observable sequence containing the elements of the source sequence starting from the point the other sequence triggered propagation.
2902
- */
2903
- observableProto.skipUntil = function (other) {
2904
- var source = this;
2905
- return new AnonymousObservable(function (observer) {
2906
- var isOpen = false;
2907
- var disposables = new CompositeDisposable(source.subscribe(function (left) {
2908
- if (isOpen) {
2909
- observer.onNext(left);
2910
- }
2911
- }, observer.onError.bind(observer), function () {
2912
- if (isOpen) {
2913
- observer.onCompleted();
2914
- }
2915
- }));
2875
+ /**
2876
+ * Returns the values from the source observable sequence only after the other observable sequence produces a value.
2877
+ * @param {Observable | Promise} other The observable sequence or Promise that triggers propagation of elements of the source sequence.
2878
+ * @returns {Observable} An observable sequence containing the elements of the source sequence starting from the point the other sequence triggered propagation.
2879
+ */
2880
+ observableProto.skipUntil = function (other) {
2881
+ var source = this;
2882
+ return new AnonymousObservable(function (observer) {
2883
+ var isOpen = false;
2884
+ var disposables = new CompositeDisposable(source.subscribe(function (left) {
2885
+ isOpen && observer.onNext(left);
2886
+ }, observer.onError.bind(observer), function () {
2887
+ isOpen && observer.onCompleted();
2888
+ }));
2916
2889
 
2917
- var rightSubscription = new SingleAssignmentDisposable();
2918
- disposables.add(rightSubscription);
2919
- rightSubscription.setDisposable(other.subscribe(function () {
2920
- isOpen = true;
2921
- rightSubscription.dispose();
2922
- }, observer.onError.bind(observer), function () {
2923
- rightSubscription.dispose();
2924
- }));
2890
+ isPromise(other) && (other = observableFromPromise(other));
2925
2891
 
2926
- return disposables;
2927
- });
2928
- };
2892
+ var rightSubscription = new SingleAssignmentDisposable();
2893
+ disposables.add(rightSubscription);
2894
+ rightSubscription.setDisposable(other.subscribe(function () {
2895
+ isOpen = true;
2896
+ rightSubscription.dispose();
2897
+ }, observer.onError.bind(observer), function () {
2898
+ rightSubscription.dispose();
2899
+ }));
2900
+
2901
+ return disposables;
2902
+ });
2903
+ };
2929
2904
 
2930
2905
  /**
2931
2906
  * Transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
@@ -2974,20 +2949,21 @@
2974
2949
  });
2975
2950
  };
2976
2951
 
2977
- /**
2978
- * Returns the values from the source observable sequence until the other observable sequence produces a value.
2979
- * @param {Observable} other Observable sequence that terminates propagation of elements of the source sequence.
2980
- * @returns {Observable} An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.
2981
- */
2982
- observableProto.takeUntil = function (other) {
2983
- var source = this;
2984
- return new AnonymousObservable(function (observer) {
2985
- return new CompositeDisposable(
2986
- source.subscribe(observer),
2987
- other.subscribe(observer.onCompleted.bind(observer), observer.onError.bind(observer), noop)
2988
- );
2989
- });
2990
- };
2952
+ /**
2953
+ * Returns the values from the source observable sequence until the other observable sequence produces a value.
2954
+ * @param {Observable | Promise} other Observable sequence or Promise that terminates propagation of elements of the source sequence.
2955
+ * @returns {Observable} An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.
2956
+ */
2957
+ observableProto.takeUntil = function (other) {
2958
+ var source = this;
2959
+ return new AnonymousObservable(function (observer) {
2960
+ isPromise(other) && (other = observableFromPromise(other));
2961
+ return new CompositeDisposable(
2962
+ source.subscribe(observer),
2963
+ other.subscribe(observer.onCompleted.bind(observer), observer.onError.bind(observer), noop)
2964
+ );
2965
+ });
2966
+ };
2991
2967
 
2992
2968
  function zipArray(second, resultSelector) {
2993
2969
  var first = this;
@@ -3147,26 +3123,26 @@
3147
3123
  });
3148
3124
  };
3149
3125
 
3150
- /**
3151
- * Projects each element of an observable sequence into zero or more buffers which are produced based on element count information.
3152
- *
3153
- * @example
3154
- * var res = xs.bufferWithCount(10);
3155
- * var res = xs.bufferWithCount(10, 1);
3156
- * @param {Number} count Length of each buffer.
3157
- * @param {Number} [skip] Number of elements to skip between creation of consecutive buffers. If not provided, defaults to the count.
3158
- * @returns {Observable} An observable sequence of buffers.
3159
- */
3160
- observableProto.bufferWithCount = function (count, skip) {
3161
- if (arguments.length === 1) {
3162
- skip = count;
3163
- }
3164
- return this.windowWithCount(count, skip).selectMany(function (x) {
3165
- return x.toArray();
3166
- }).where(function (x) {
3167
- return x.length > 0;
3168
- });
3169
- };
3126
+ /**
3127
+ * Projects each element of an observable sequence into zero or more buffers which are produced based on element count information.
3128
+ *
3129
+ * @example
3130
+ * var res = xs.bufferWithCount(10);
3131
+ * var res = xs.bufferWithCount(10, 1);
3132
+ * @param {Number} count Length of each buffer.
3133
+ * @param {Number} [skip] Number of elements to skip between creation of consecutive buffers. If not provided, defaults to the count.
3134
+ * @returns {Observable} An observable sequence of buffers.
3135
+ */
3136
+ observableProto.bufferWithCount = function (count, skip) {
3137
+ if (typeof skip !== 'number') {
3138
+ skip = count;
3139
+ }
3140
+ return this.windowWithCount(count, skip).selectMany(function (x) {
3141
+ return x.toArray();
3142
+ }).where(function (x) {
3143
+ return x.length > 0;
3144
+ });
3145
+ };
3170
3146
 
3171
3147
  /**
3172
3148
  * Dematerializes the explicit notification values of an observable sequence as implicit notifications.
@@ -3280,29 +3256,35 @@
3280
3256
  });
3281
3257
  };
3282
3258
 
3283
- /**
3284
- * Invokes a specified action after the source observable sequence terminates gracefully or exceptionally.
3285
- *
3286
- * @example
3287
- * var res = observable.finallyAction(function () { console.log('sequence ended'; });
3288
- * @param {Function} finallyAction Action to invoke after the source observable sequence terminates.
3289
- * @returns {Observable} Source sequence with the action-invoking termination behavior applied.
3290
- */
3291
- observableProto['finally'] = observableProto.finallyAction = function (action) {
3292
- var source = this;
3293
- return new AnonymousObservable(function (observer) {
3294
- var subscription = source.subscribe(observer);
3295
- return disposableCreate(function () {
3296
- try {
3297
- subscription.dispose();
3298
- } catch (e) {
3299
- throw e;
3300
- } finally {
3301
- action();
3302
- }
3303
- });
3304
- });
3305
- };
3259
+ /**
3260
+ * Invokes a specified action after the source observable sequence terminates gracefully or exceptionally.
3261
+ *
3262
+ * @example
3263
+ * var res = observable.finallyAction(function () { console.log('sequence ended'; });
3264
+ * @param {Function} finallyAction Action to invoke after the source observable sequence terminates.
3265
+ * @returns {Observable} Source sequence with the action-invoking termination behavior applied.
3266
+ */
3267
+ observableProto['finally'] = observableProto.finallyAction = function (action) {
3268
+ var source = this;
3269
+ return new AnonymousObservable(function (observer) {
3270
+ var subscription;
3271
+ try {
3272
+ subscription = source.subscribe(observer);
3273
+ } catch (e) {
3274
+ action();
3275
+ throw e;
3276
+ }
3277
+ return disposableCreate(function () {
3278
+ try {
3279
+ subscription.dispose();
3280
+ } catch (e) {
3281
+ throw e;
3282
+ } finally {
3283
+ action();
3284
+ }
3285
+ });
3286
+ });
3287
+ };
3306
3288
 
3307
3289
  /**
3308
3290
  * Ignores all elements in an observable sequence leaving only the termination messages.
@@ -3557,6 +3539,71 @@
3557
3539
  });
3558
3540
  };
3559
3541
 
3542
+ function concatMap(selector) {
3543
+ return this.map(function (x, i) {
3544
+ var result = selector(x, i);
3545
+ return isPromise(result) ? observableFromPromise(result) : result;
3546
+ }).concatAll();
3547
+ }
3548
+
3549
+ function concatMapObserver(onNext, onError, onCompleted) {
3550
+ var source = this;
3551
+ return new AnonymousObservable(function (observer) {
3552
+ var index = 0;
3553
+
3554
+ return source.subscribe(
3555
+ function (x) {
3556
+ observer.onNext(onNext(x, index++));
3557
+ },
3558
+ function (err) {
3559
+ observer.onNext(onError(err));
3560
+ observer.completed();
3561
+ },
3562
+ function () {
3563
+ observer.onNext(onCompleted());
3564
+ observer.onCompleted();
3565
+ });
3566
+ }).concatAll();
3567
+ }
3568
+
3569
+ /**
3570
+ * One of the Following:
3571
+ * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
3572
+ *
3573
+ * @example
3574
+ * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); });
3575
+ * Or:
3576
+ * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
3577
+ *
3578
+ * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
3579
+ * Or:
3580
+ * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
3581
+ *
3582
+ * var res = source.selectMany(Rx.Observable.fromArray([1,2,3]));
3583
+ * @param selector A transform function to apply to each element or an observable sequence to project each element from the
3584
+ * source sequence onto which could be either an observable or Promise.
3585
+ * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
3586
+ * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
3587
+ */
3588
+ observableProto.selectConcat = observableProto.concatMap = function (selector, resultSelector) {
3589
+ if (resultSelector) {
3590
+ return this.concatMap(function (x, i) {
3591
+ var selectorResult = selector(x, i),
3592
+ result = isPromise(selectorResult) ? observableFromPromise(selectorResult) : selectorResult;
3593
+
3594
+ return result.map(function (y) {
3595
+ return resultSelector(x, y, i);
3596
+ });
3597
+ });
3598
+ }
3599
+ if (typeof selector === 'function') {
3600
+ return concatMap.call(this, selector);
3601
+ }
3602
+ return concatMap.call(this, function () {
3603
+ return selector;
3604
+ });
3605
+ };
3606
+
3560
3607
  /**
3561
3608
  * Returns the elements of the specified sequence or the specified value in a singleton sequence if the sequence is empty.
3562
3609
  *
@@ -3792,6 +3839,26 @@
3792
3839
  }).mergeObservable();
3793
3840
  }
3794
3841
 
3842
+ function selectManyObserver(onNext, onError, onCompleted) {
3843
+ var source = this;
3844
+ return new AnonymousObservable(function (observer) {
3845
+ var index = 0;
3846
+
3847
+ return source.subscribe(
3848
+ function (x) {
3849
+ observer.onNext(onNext(x, index++));
3850
+ },
3851
+ function (err) {
3852
+ observer.onNext(onError(err));
3853
+ observer.completed();
3854
+ },
3855
+ function () {
3856
+ observer.onNext(onCompleted());
3857
+ observer.onCompleted();
3858
+ });
3859
+ }).mergeAll();
3860
+ }
3861
+
3795
3862
  /**
3796
3863
  * One of the Following:
3797
3864
  * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
@@ -3987,56 +4054,56 @@
3987
4054
  });
3988
4055
  };
3989
4056
 
3990
- var AnonymousObservable = Rx.AnonymousObservable = (function (_super) {
3991
- inherits(AnonymousObservable, _super);
3992
-
3993
- // Fix subscriber to check for undefined or function returned to decorate as Disposable
3994
- function fixSubscriber(subscriber) {
3995
- if (typeof subscriber === 'undefined') {
3996
- subscriber = disposableEmpty;
3997
- } else if (typeof subscriber === 'function') {
3998
- subscriber = disposableCreate(subscriber);
3999
- }
4057
+ var AnonymousObservable = Rx.AnonymousObservable = (function (__super__) {
4058
+ inherits(AnonymousObservable, __super__);
4000
4059
 
4001
- return subscriber;
4002
- }
4060
+ // Fix subscriber to check for undefined or function returned to decorate as Disposable
4061
+ function fixSubscriber(subscriber) {
4062
+ if (typeof subscriber === 'undefined') {
4063
+ subscriber = disposableEmpty;
4064
+ } else if (typeof subscriber === 'function') {
4065
+ subscriber = disposableCreate(subscriber);
4066
+ }
4003
4067
 
4004
- function AnonymousObservable(subscribe) {
4005
- if (!(this instanceof AnonymousObservable)) {
4006
- return new AnonymousObservable(subscribe);
4007
- }
4068
+ return subscriber;
4069
+ }
4008
4070
 
4009
- function s(observer) {
4010
- var autoDetachObserver = new AutoDetachObserver(observer);
4011
- if (currentThreadScheduler.scheduleRequired()) {
4012
- currentThreadScheduler.schedule(function () {
4013
- try {
4014
- autoDetachObserver.setDisposable(fixSubscriber(subscribe(autoDetachObserver)));
4015
- } catch (e) {
4016
- if (!autoDetachObserver.fail(e)) {
4017
- throw e;
4018
- }
4019
- }
4020
- });
4021
- } else {
4022
- try {
4023
- autoDetachObserver.setDisposable(fixSubscriber(subscribe(autoDetachObserver)));
4024
- } catch (e) {
4025
- if (!autoDetachObserver.fail(e)) {
4026
- throw e;
4027
- }
4028
- }
4029
- }
4071
+ function AnonymousObservable(subscribe) {
4072
+ if (!(this instanceof AnonymousObservable)) {
4073
+ return new AnonymousObservable(subscribe);
4074
+ }
4030
4075
 
4031
- return autoDetachObserver;
4076
+ function s(observer) {
4077
+ var autoDetachObserver = new AutoDetachObserver(observer);
4078
+ if (currentThreadScheduler.scheduleRequired()) {
4079
+ currentThreadScheduler.schedule(function () {
4080
+ try {
4081
+ autoDetachObserver.setDisposable(fixSubscriber(subscribe(autoDetachObserver)));
4082
+ } catch (e) {
4083
+ if (!autoDetachObserver.fail(e)) {
4084
+ throw e;
4085
+ }
4032
4086
  }
4033
-
4034
- _super.call(this, s);
4087
+ });
4088
+ } else {
4089
+ try {
4090
+ autoDetachObserver.setDisposable(fixSubscriber(subscribe(autoDetachObserver)));
4091
+ } catch (e) {
4092
+ if (!autoDetachObserver.fail(e)) {
4093
+ throw e;
4094
+ }
4095
+ }
4035
4096
  }
4036
4097
 
4037
- return AnonymousObservable;
4098
+ return autoDetachObserver;
4099
+ }
4038
4100
 
4039
- }(Observable));
4101
+ __super__.call(this, s);
4102
+ }
4103
+
4104
+ return AnonymousObservable;
4105
+
4106
+ }(Observable));
4040
4107
 
4041
4108
  /** @private */
4042
4109
  var AutoDetachObserver = (function (_super) {
@@ -4099,48 +4166,48 @@
4099
4166
  return AutoDetachObserver;
4100
4167
  }(AbstractObserver));
4101
4168
 
4102
- /** @private */
4103
- var GroupedObservable = (function (_super) {
4104
- inherits(GroupedObservable, _super);
4105
-
4106
- function subscribe(observer) {
4107
- return this.underlyingObservable.subscribe(observer);
4108
- }
4109
-
4110
- /**
4111
- * @constructor
4112
- * @private
4113
- */
4114
- function GroupedObservable(key, underlyingObservable, mergedDisposable) {
4115
- _super.call(this, subscribe);
4116
- this.key = key;
4117
- this.underlyingObservable = !mergedDisposable ?
4118
- underlyingObservable :
4119
- new AnonymousObservable(function (observer) {
4120
- return new CompositeDisposable(mergedDisposable.getDisposable(), underlyingObservable.subscribe(observer));
4121
- });
4122
- }
4123
-
4124
- return GroupedObservable;
4125
- }(Observable));
4126
-
4127
- /** @private */
4128
- var InnerSubscription = function (subject, observer) {
4129
- this.subject = subject;
4130
- this.observer = observer;
4131
- };
4132
-
4133
- /**
4134
- * @private
4135
- * @memberOf InnerSubscription
4136
- */
4137
- InnerSubscription.prototype.dispose = function () {
4138
- if (!this.subject.isDisposed && this.observer !== null) {
4139
- var idx = this.subject.observers.indexOf(this.observer);
4140
- this.subject.observers.splice(idx, 1);
4141
- this.observer = null;
4142
- }
4143
- };
4169
+ /** @private */
4170
+ var GroupedObservable = (function (_super) {
4171
+ inherits(GroupedObservable, _super);
4172
+
4173
+ function subscribe(observer) {
4174
+ return this.underlyingObservable.subscribe(observer);
4175
+ }
4176
+
4177
+ /**
4178
+ * @constructor
4179
+ * @private
4180
+ */
4181
+ function GroupedObservable(key, underlyingObservable, mergedDisposable) {
4182
+ _super.call(this, subscribe);
4183
+ this.key = key;
4184
+ this.underlyingObservable = !mergedDisposable ?
4185
+ underlyingObservable :
4186
+ new AnonymousObservable(function (observer) {
4187
+ return new CompositeDisposable(mergedDisposable.getDisposable(), underlyingObservable.subscribe(observer));
4188
+ });
4189
+ }
4190
+
4191
+ return GroupedObservable;
4192
+ }(Observable));
4193
+
4194
+ /** @private */
4195
+ var InnerSubscription = function (subject, observer) {
4196
+ this.subject = subject;
4197
+ this.observer = observer;
4198
+ };
4199
+
4200
+ /**
4201
+ * @private
4202
+ * @memberOf InnerSubscription
4203
+ */
4204
+ InnerSubscription.prototype.dispose = function () {
4205
+ if (!this.subject.isDisposed && this.observer !== null) {
4206
+ var idx = this.subject.observers.indexOf(this.observer);
4207
+ this.subject.observers.splice(idx, 1);
4208
+ this.observer = null;
4209
+ }
4210
+ };
4144
4211
 
4145
4212
  /**
4146
4213
  * Represents an object that is both an observable sequence as well as an observer.
@@ -4375,66 +4442,66 @@
4375
4442
  return AsyncSubject;
4376
4443
  }(Observable));
4377
4444
 
4378
- /** @private */
4379
- var AnonymousSubject = (function (_super) {
4380
- inherits(AnonymousSubject, _super);
4381
-
4382
- function subscribe(observer) {
4383
- return this.observable.subscribe(observer);
4384
- }
4385
-
4386
- /**
4387
- * @private
4388
- * @constructor
4389
- */
4390
- function AnonymousSubject(observer, observable) {
4391
- _super.call(this, subscribe);
4392
- this.observer = observer;
4393
- this.observable = observable;
4394
- }
4395
-
4396
- addProperties(AnonymousSubject.prototype, Observer, {
4397
- /**
4398
- * @private
4399
- * @memberOf AnonymousSubject#
4400
- */
4401
- onCompleted: function () {
4402
- this.observer.onCompleted();
4403
- },
4404
- /**
4405
- * @private
4406
- * @memberOf AnonymousSubject#
4407
- */
4408
- onError: function (exception) {
4409
- this.observer.onError(exception);
4410
- },
4411
- /**
4412
- * @private
4413
- * @memberOf AnonymousSubject#
4414
- */
4415
- onNext: function (value) {
4416
- this.observer.onNext(value);
4417
- }
4418
- });
4419
-
4420
- return AnonymousSubject;
4421
- }(Observable));
4422
-
4423
- if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
4424
- root.Rx = Rx;
4425
-
4426
- define(function() {
4427
- return Rx;
4428
- });
4429
- } else if (freeExports && freeModule) {
4430
- // in Node.js or RingoJS
4431
- if (moduleExports) {
4432
- (freeModule.exports = Rx).Rx = Rx;
4433
- } else {
4434
- freeExports.Rx = Rx;
4435
- }
4436
- } else {
4437
- // in a browser or Rhino
4438
- root.Rx = Rx;
4445
+ /** @private */
4446
+ var AnonymousSubject = (function (_super) {
4447
+ inherits(AnonymousSubject, _super);
4448
+
4449
+ function subscribe(observer) {
4450
+ return this.observable.subscribe(observer);
4451
+ }
4452
+
4453
+ /**
4454
+ * @private
4455
+ * @constructor
4456
+ */
4457
+ function AnonymousSubject(observer, observable) {
4458
+ _super.call(this, subscribe);
4459
+ this.observer = observer;
4460
+ this.observable = observable;
4461
+ }
4462
+
4463
+ addProperties(AnonymousSubject.prototype, Observer, {
4464
+ /**
4465
+ * @private
4466
+ * @memberOf AnonymousSubject#
4467
+ */
4468
+ onCompleted: function () {
4469
+ this.observer.onCompleted();
4470
+ },
4471
+ /**
4472
+ * @private
4473
+ * @memberOf AnonymousSubject#
4474
+ */
4475
+ onError: function (exception) {
4476
+ this.observer.onError(exception);
4477
+ },
4478
+ /**
4479
+ * @private
4480
+ * @memberOf AnonymousSubject#
4481
+ */
4482
+ onNext: function (value) {
4483
+ this.observer.onNext(value);
4484
+ }
4485
+ });
4486
+
4487
+ return AnonymousSubject;
4488
+ }(Observable));
4489
+
4490
+ if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
4491
+ root.Rx = Rx;
4492
+
4493
+ define(function() {
4494
+ return Rx;
4495
+ });
4496
+ } else if (freeExports && freeModule) {
4497
+ // in Node.js or RingoJS
4498
+ if (moduleExports) {
4499
+ (freeModule.exports = Rx).Rx = Rx;
4500
+ } else {
4501
+ freeExports.Rx = Rx;
4502
+ }
4503
+ } else {
4504
+ // in a browser or Rhino
4505
+ root.Rx = Rx;
4439
4506
  }
4440
4507
  }.call(this));