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 (undefined) {
4
4
 
@@ -16,26 +16,26 @@
16
16
  freeModule = objectTypes[typeof module] && module && !module.nodeType && module,
17
17
  moduleExports = freeModule && freeModule.exports === freeExports && freeExports,
18
18
  freeGlobal = objectTypes[typeof global] && global;
19
-
19
+
20
20
  if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) {
21
21
  root = freeGlobal;
22
22
  }
23
23
 
24
- var Rx = {
25
- internals: {},
24
+ var Rx = {
25
+ internals: {},
26
26
  config: {
27
27
  Promise: root.Promise // Detect if promise exists
28
28
  },
29
29
  helpers: { }
30
30
  };
31
-
31
+
32
32
  // Defaults
33
33
  var noop = Rx.helpers.noop = function () { },
34
- notDefined = Rx.helpers.notDefined = function (x) { return typeof x === 'undefined'; },
35
- isScheduler = Rx.helpers.isScheduler = function (x) { return x instanceof Rx.Scheduler; },
34
+ notDefined = Rx.helpers.notDefined = function (x) { return typeof x === 'undefined'; },
35
+ isScheduler = Rx.helpers.isScheduler = function (x) { return x instanceof Rx.Scheduler; },
36
36
  identity = Rx.helpers.identity = function (x) { return x; },
37
37
  pluck = Rx.helpers.pluck = function (property) { return function (x) { return x[property]; }; },
38
- just = Rx.helpers.just = function (value) { return function () { return value; }; },
38
+ just = Rx.helpers.just = function (value) { return function () { return value; }; },
39
39
  defaultNow = Rx.helpers.defaultNow = Date.now,
40
40
  defaultComparer = Rx.helpers.defaultComparer = function (x, y) { return isEqual(x, y); },
41
41
  defaultSubComparer = Rx.helpers.defaultSubComparer = function (x, y) { return x > y ? 1 : (x < y ? -1 : 0); },
@@ -55,17 +55,17 @@
55
55
  isFn = function(value) {
56
56
  return typeof value == 'function' && toString.call(value) == '[object Function]';
57
57
  };
58
- }
58
+ }
59
59
 
60
60
  return isFn;
61
- }());
61
+ }());
62
62
 
63
63
  // Errors
64
64
  var sequenceContainsNoElements = 'Sequence contains no elements.';
65
65
  var argumentOutOfRange = 'Argument out of range';
66
66
  var objectDisposed = 'Object has been disposed';
67
- function checkDisposed() { if (this.isDisposed) { throw new Error(objectDisposed); } }
68
-
67
+ function checkDisposed() { if (this.isDisposed) { throw new Error(objectDisposed); } }
68
+
69
69
  // Shim in iterator support
70
70
  var $iterator$ = (typeof Symbol === 'function' && Symbol.iterator) ||
71
71
  '_es6shim_iterator_';
@@ -73,8 +73,10 @@
73
73
  if (root.Set && typeof new root.Set()['@@iterator'] === 'function') {
74
74
  $iterator$ = '@@iterator';
75
75
  }
76
-
77
- var doneEnumerator = { done: true, value: undefined };
76
+
77
+ var doneEnumerator = Rx.doneEnumerator = { done: true, value: undefined };
78
+
79
+ Rx.iterator = $iterator$;
78
80
 
79
81
  /** `Object#toString` result shortcuts */
80
82
  var argsClass = '[object Arguments]',
@@ -89,7 +91,7 @@
89
91
  stringClass = '[object String]';
90
92
 
91
93
  var toString = Object.prototype.toString,
92
- hasOwnProperty = Object.prototype.hasOwnProperty,
94
+ hasOwnProperty = Object.prototype.hasOwnProperty,
93
95
  supportsArgsClass = toString.call(arguments) == argsClass, // For less <IE9 && FF<4
94
96
  suportNodeClass,
95
97
  errorProto = Error.prototype,
@@ -118,7 +120,7 @@
118
120
  props = [];
119
121
 
120
122
  ctor.prototype = { 'valueOf': 1, 'y': 1 };
121
- for (var key in new ctor) { props.push(key); }
123
+ for (var key in new ctor) { props.push(key); }
122
124
  for (key in arguments) { }
123
125
 
124
126
  // Detect if `name` or `message` properties of `Error.prototype` are enumerable by default.
@@ -192,7 +194,7 @@
192
194
  }
193
195
  }
194
196
  return object;
195
- }
197
+ }
196
198
 
197
199
  function internalForIn(object, callback) {
198
200
  return internalFor(object, callback, keysIn);
@@ -213,10 +215,10 @@
213
215
  isArguments = function(value) {
214
216
  return (value && typeof value == 'object') ? hasOwnProperty.call(value, 'callee') : false;
215
217
  };
216
- }
218
+ }
217
219
 
218
220
  var isEqual = Rx.internals.isEqual = function (x, y) {
219
- return deepEquals(x, y, [], []);
221
+ return deepEquals(x, y, [], []);
220
222
  };
221
223
 
222
224
  /** @private
@@ -357,133 +359,132 @@
357
359
 
358
360
  return result;
359
361
  }
360
- var slice = Array.prototype.slice;
361
- function argsOrArray(args, idx) {
362
- return args.length === 1 && Array.isArray(args[idx]) ?
363
- args[idx] :
364
- slice.call(args);
362
+
363
+ var slice = Array.prototype.slice;
364
+ function argsOrArray(args, idx) {
365
+ return args.length === 1 && Array.isArray(args[idx]) ?
366
+ args[idx] :
367
+ slice.call(args);
368
+ }
369
+ var hasProp = {}.hasOwnProperty;
370
+
371
+ var inherits = this.inherits = Rx.internals.inherits = function (child, parent) {
372
+ function __() { this.constructor = child; }
373
+ __.prototype = parent.prototype;
374
+ child.prototype = new __();
375
+ };
376
+
377
+ var addProperties = Rx.internals.addProperties = function (obj) {
378
+ var sources = slice.call(arguments, 1);
379
+ for (var i = 0, len = sources.length; i < len; i++) {
380
+ var source = sources[i];
381
+ for (var prop in source) {
382
+ obj[prop] = source[prop];
383
+ }
365
384
  }
366
- var hasProp = {}.hasOwnProperty;
385
+ };
367
386
 
368
- /** @private */
369
- var inherits = this.inherits = Rx.internals.inherits = function (child, parent) {
370
- function __() { this.constructor = child; }
371
- __.prototype = parent.prototype;
372
- child.prototype = new __();
373
- };
387
+ // Rx Utils
388
+ var addRef = Rx.internals.addRef = function (xs, r) {
389
+ return new AnonymousObservable(function (observer) {
390
+ return new CompositeDisposable(r.getDisposable(), xs.subscribe(observer));
391
+ });
392
+ };
374
393
 
375
- /** @private */
376
- var addProperties = Rx.internals.addProperties = function (obj) {
377
- var sources = slice.call(arguments, 1);
378
- for (var i = 0, len = sources.length; i < len; i++) {
379
- var source = sources[i];
380
- for (var prop in source) {
381
- obj[prop] = source[prop];
382
- }
383
- }
384
- };
394
+ function arrayInitialize(count, factory) {
395
+ var a = new Array(count);
396
+ for (var i = 0; i < count; i++) {
397
+ a[i] = factory();
398
+ }
399
+ return a;
400
+ }
385
401
 
386
- // Rx Utils
387
- var addRef = Rx.internals.addRef = function (xs, r) {
388
- return new AnonymousObservable(function (observer) {
389
- return new CompositeDisposable(r.getDisposable(), xs.subscribe(observer));
390
- });
391
- };
402
+ // Collections
403
+ function IndexedItem(id, value) {
404
+ this.id = id;
405
+ this.value = value;
406
+ }
392
407
 
393
- // Collection polyfills
394
- function arrayInitialize(count, factory) {
395
- var a = new Array(count);
396
- for (var i = 0; i < count; i++) {
397
- a[i] = factory();
398
- }
399
- return a;
408
+ IndexedItem.prototype.compareTo = function (other) {
409
+ var c = this.value.compareTo(other.value);
410
+ c === 0 && (c = this.id - other.id);
411
+ return c;
412
+ };
413
+
414
+ // Priority Queue for Scheduling
415
+ var PriorityQueue = Rx.internals.PriorityQueue = function (capacity) {
416
+ this.items = new Array(capacity);
417
+ this.length = 0;
418
+ };
419
+
420
+ var priorityProto = PriorityQueue.prototype;
421
+ priorityProto.isHigherPriority = function (left, right) {
422
+ return this.items[left].compareTo(this.items[right]) < 0;
423
+ };
424
+
425
+ priorityProto.percolate = function (index) {
426
+ if (index >= this.length || index < 0) { return; }
427
+ var parent = index - 1 >> 1;
428
+ if (parent < 0 || parent === index) { return; }
429
+ if (this.isHigherPriority(index, parent)) {
430
+ var temp = this.items[index];
431
+ this.items[index] = this.items[parent];
432
+ this.items[parent] = temp;
433
+ this.percolate(parent);
434
+ }
435
+ };
436
+
437
+ priorityProto.heapify = function (index) {
438
+ +index || (index = 0);
439
+ if (index >= this.length || index < 0) { return; }
440
+ var left = 2 * index + 1,
441
+ right = 2 * index + 2,
442
+ first = index;
443
+ if (left < this.length && this.isHigherPriority(left, first)) {
444
+ first = left;
445
+ }
446
+ if (right < this.length && this.isHigherPriority(right, first)) {
447
+ first = right;
400
448
  }
449
+ if (first !== index) {
450
+ var temp = this.items[index];
451
+ this.items[index] = this.items[first];
452
+ this.items[first] = temp;
453
+ this.heapify(first);
454
+ }
455
+ };
456
+
457
+ priorityProto.peek = function () { return this.items[0].value; };
458
+
459
+ priorityProto.removeAt = function (index) {
460
+ this.items[index] = this.items[--this.length];
461
+ delete this.items[this.length];
462
+ this.heapify();
463
+ };
464
+
465
+ priorityProto.dequeue = function () {
466
+ var result = this.peek();
467
+ this.removeAt(0);
468
+ return result;
469
+ };
401
470
 
402
- // Collections
403
- function IndexedItem(id, value) {
404
- this.id = id;
405
- this.value = value;
406
- }
407
-
408
- IndexedItem.prototype.compareTo = function (other) {
409
- var c = this.value.compareTo(other.value);
410
- c === 0 && (c = this.id - other.id);
411
- return c;
412
- };
413
-
414
- // Priority Queue for Scheduling
415
- var PriorityQueue = Rx.internals.PriorityQueue = function (capacity) {
416
- this.items = new Array(capacity);
417
- this.length = 0;
418
- };
419
-
420
- var priorityProto = PriorityQueue.prototype;
421
- priorityProto.isHigherPriority = function (left, right) {
422
- return this.items[left].compareTo(this.items[right]) < 0;
423
- };
424
-
425
- priorityProto.percolate = function (index) {
426
- if (index >= this.length || index < 0) { return; }
427
- var parent = index - 1 >> 1;
428
- if (parent < 0 || parent === index) { return; }
429
- if (this.isHigherPriority(index, parent)) {
430
- var temp = this.items[index];
431
- this.items[index] = this.items[parent];
432
- this.items[parent] = temp;
433
- this.percolate(parent);
434
- }
435
- };
436
-
437
- priorityProto.heapify = function (index) {
438
- +index || (index = 0);
439
- if (index >= this.length || index < 0) { return; }
440
- var left = 2 * index + 1,
441
- right = 2 * index + 2,
442
- first = index;
443
- if (left < this.length && this.isHigherPriority(left, first)) {
444
- first = left;
445
- }
446
- if (right < this.length && this.isHigherPriority(right, first)) {
447
- first = right;
448
- }
449
- if (first !== index) {
450
- var temp = this.items[index];
451
- this.items[index] = this.items[first];
452
- this.items[first] = temp;
453
- this.heapify(first);
454
- }
455
- };
456
-
457
- priorityProto.peek = function () { return this.items[0].value; };
458
-
459
- priorityProto.removeAt = function (index) {
460
- this.items[index] = this.items[--this.length];
461
- delete this.items[this.length];
462
- this.heapify();
463
- };
464
-
465
- priorityProto.dequeue = function () {
466
- var result = this.peek();
467
- this.removeAt(0);
468
- return result;
469
- };
470
-
471
- priorityProto.enqueue = function (item) {
472
- var index = this.length++;
473
- this.items[index] = new IndexedItem(PriorityQueue.count++, item);
474
- this.percolate(index);
475
- };
476
-
477
- priorityProto.remove = function (item) {
478
- for (var i = 0; i < this.length; i++) {
479
- if (this.items[i].value === item) {
480
- this.removeAt(i);
481
- return true;
482
- }
483
- }
484
- return false;
485
- };
471
+ priorityProto.enqueue = function (item) {
472
+ var index = this.length++;
473
+ this.items[index] = new IndexedItem(PriorityQueue.count++, item);
474
+ this.percolate(index);
475
+ };
476
+
477
+ priorityProto.remove = function (item) {
478
+ for (var i = 0; i < this.length; i++) {
479
+ if (this.items[i].value === item) {
480
+ this.removeAt(i);
481
+ return true;
482
+ }
483
+ }
484
+ return false;
485
+ };
486
486
  PriorityQueue.count = 0;
487
+
487
488
  /**
488
489
  * Represents a group of disposable resources that are disposed together.
489
490
  * @constructor
@@ -499,7 +500,7 @@
499
500
  /**
500
501
  * Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed.
501
502
  * @param {Mixed} item Disposable to add.
502
- */
503
+ */
503
504
  CompositeDisposablePrototype.add = function (item) {
504
505
  if (this.isDisposed) {
505
506
  item.dispose();
@@ -529,7 +530,7 @@
529
530
  };
530
531
 
531
532
  /**
532
- * Disposes all disposables in the group and removes them from the group.
533
+ * Disposes all disposables in the group and removes them from the group.
533
534
  */
534
535
  CompositeDisposablePrototype.dispose = function () {
535
536
  if (!this.isDisposed) {
@@ -547,15 +548,15 @@
547
548
  /**
548
549
  * Converts the existing CompositeDisposable to an array of disposables
549
550
  * @returns {Array} An array of disposable objects.
550
- */
551
+ */
551
552
  CompositeDisposablePrototype.toArray = function () {
552
553
  return this.disposables.slice(0);
553
554
  };
554
-
555
+
555
556
  /**
556
557
  * Provides a set of static methods for creating Disposables.
557
558
  *
558
- * @constructor
559
+ * @constructor
559
560
  * @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once.
560
561
  */
561
562
  var Disposable = Rx.Disposable = function (action) {
@@ -563,7 +564,7 @@
563
564
  this.action = action || noop;
564
565
  };
565
566
 
566
- /** Performs the task of cleaning up resources. */
567
+ /** Performs the task of cleaning up resources. */
567
568
  Disposable.prototype.dispose = function () {
568
569
  if (!this.isDisposed) {
569
570
  this.action();
@@ -578,8 +579,8 @@
578
579
  */
579
580
  var disposableCreate = Disposable.create = function (action) { return new Disposable(action); };
580
581
 
581
- /**
582
- * Gets the disposable that does nothing when disposed.
582
+ /**
583
+ * Gets the disposable that does nothing when disposed.
583
584
  */
584
585
  var disposableEmpty = Disposable.empty = { dispose: noop };
585
586
 
@@ -602,7 +603,7 @@
602
603
  /**
603
604
  * Sets the underlying disposable.
604
605
  * @param {Disposable} value The new underlying disposable.
605
- */
606
+ */
606
607
  booleanDisposablePrototype.setDisposable = function (value) {
607
608
  var shouldDispose = this.isDisposed, old;
608
609
  if (!shouldDispose) {
@@ -613,7 +614,7 @@
613
614
  shouldDispose && value && value.dispose();
614
615
  };
615
616
 
616
- /**
617
+ /**
617
618
  * Disposes the underlying disposable as well as all future replacements.
618
619
  */
619
620
  booleanDisposablePrototype.dispose = function () {
@@ -629,9 +630,10 @@
629
630
  return BooleanDisposable;
630
631
  }());
631
632
  var SerialDisposable = Rx.SerialDisposable = SingleAssignmentDisposable;
633
+
632
634
  /**
633
635
  * Represents a disposable resource that only disposes its underlying disposable resource when all dependent disposable objects have been disposed.
634
- */
636
+ */
635
637
  var RefCountDisposable = Rx.RefCountDisposable = (function () {
636
638
 
637
639
  function InnerDisposable(disposable) {
@@ -665,8 +667,8 @@
665
667
  this.count = 0;
666
668
  }
667
669
 
668
- /**
669
- * Disposes the underlying disposable only when all dependent disposables have been disposed
670
+ /**
671
+ * Disposes the underlying disposable only when all dependent disposables have been disposed
670
672
  */
671
673
  RefCountDisposable.prototype.dispose = function () {
672
674
  if (!this.isDisposed) {
@@ -681,9 +683,9 @@
681
683
  };
682
684
 
683
685
  /**
684
- * Returns a dependent disposable that when disposed decreases the refcount on the underlying disposable.
686
+ * Returns a dependent disposable that when disposed decreases the refcount on the underlying disposable.
685
687
  * @returns {Disposable} A dependent disposable contributing to the reference count that manages the underlying disposable's lifetime.
686
- */
688
+ */
687
689
  RefCountDisposable.prototype.getDisposable = function () {
688
690
  return this.isDisposed ? disposableEmpty : new InnerDisposable(this);
689
691
  };
@@ -691,46 +693,46 @@
691
693
  return RefCountDisposable;
692
694
  })();
693
695
 
694
- function ScheduledDisposable(scheduler, disposable) {
695
- this.scheduler = scheduler;
696
- this.disposable = disposable;
697
- this.isDisposed = false;
698
- }
699
-
700
- ScheduledDisposable.prototype.dispose = function () {
701
- var parent = this;
702
- this.scheduler.schedule(function () {
703
- if (!parent.isDisposed) {
704
- parent.isDisposed = true;
705
- parent.disposable.dispose();
706
- }
707
- });
708
- };
709
-
710
- var ScheduledItem = Rx.internals.ScheduledItem = function (scheduler, state, action, dueTime, comparer) {
711
- this.scheduler = scheduler;
712
- this.state = state;
713
- this.action = action;
714
- this.dueTime = dueTime;
715
- this.comparer = comparer || defaultSubComparer;
716
- this.disposable = new SingleAssignmentDisposable();
717
- }
718
-
719
- ScheduledItem.prototype.invoke = function () {
720
- this.disposable.setDisposable(this.invokeCore());
721
- };
722
-
723
- ScheduledItem.prototype.compareTo = function (other) {
724
- return this.comparer(this.dueTime, other.dueTime);
725
- };
726
-
727
- ScheduledItem.prototype.isCancelled = function () {
728
- return this.disposable.isDisposed;
729
- };
730
-
731
- ScheduledItem.prototype.invokeCore = function () {
732
- return this.action(this.scheduler, this.state);
733
- };
696
+ function ScheduledDisposable(scheduler, disposable) {
697
+ this.scheduler = scheduler;
698
+ this.disposable = disposable;
699
+ this.isDisposed = false;
700
+ }
701
+
702
+ ScheduledDisposable.prototype.dispose = function () {
703
+ var parent = this;
704
+ this.scheduler.schedule(function () {
705
+ if (!parent.isDisposed) {
706
+ parent.isDisposed = true;
707
+ parent.disposable.dispose();
708
+ }
709
+ });
710
+ };
711
+
712
+ var ScheduledItem = Rx.internals.ScheduledItem = function (scheduler, state, action, dueTime, comparer) {
713
+ this.scheduler = scheduler;
714
+ this.state = state;
715
+ this.action = action;
716
+ this.dueTime = dueTime;
717
+ this.comparer = comparer || defaultSubComparer;
718
+ this.disposable = new SingleAssignmentDisposable();
719
+ }
720
+
721
+ ScheduledItem.prototype.invoke = function () {
722
+ this.disposable.setDisposable(this.invokeCore());
723
+ };
724
+
725
+ ScheduledItem.prototype.compareTo = function (other) {
726
+ return this.comparer(this.dueTime, other.dueTime);
727
+ };
728
+
729
+ ScheduledItem.prototype.isCancelled = function () {
730
+ return this.disposable.isDisposed;
731
+ };
732
+
733
+ ScheduledItem.prototype.invokeCore = function () {
734
+ return this.action(this.scheduler, this.state);
735
+ };
734
736
 
735
737
  /** Provides a set of static properties to access commonly used schedulers. */
736
738
  var Scheduler = Rx.Scheduler = (function () {
@@ -798,7 +800,7 @@
798
800
  var schedulerProto = Scheduler.prototype;
799
801
 
800
802
  /**
801
- * Schedules an action to be executed.
803
+ * Schedules an action to be executed.
802
804
  * @param {Function} action Action to execute.
803
805
  * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
804
806
  */
@@ -807,7 +809,7 @@
807
809
  };
808
810
 
809
811
  /**
810
- * Schedules an action to be executed.
812
+ * Schedules an action to be executed.
811
813
  * @param state State passed to the action to be executed.
812
814
  * @param {Function} action Action to be executed.
813
815
  * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
@@ -817,7 +819,7 @@
817
819
  };
818
820
 
819
821
  /**
820
- * Schedules an action to be executed after the specified relative due time.
822
+ * Schedules an action to be executed after the specified relative due time.
821
823
  * @param {Function} action Action to execute.
822
824
  * @param {Number} dueTime Relative time after which to execute the action.
823
825
  * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
@@ -827,7 +829,7 @@
827
829
  };
828
830
 
829
831
  /**
830
- * Schedules an action to be executed after dueTime.
832
+ * Schedules an action to be executed after dueTime.
831
833
  * @param state State passed to the action to be executed.
832
834
  * @param {Function} action Action to be executed.
833
835
  * @param {Number} dueTime Relative time after which to execute the action.
@@ -838,7 +840,7 @@
838
840
  };
839
841
 
840
842
  /**
841
- * Schedules an action to be executed at the specified absolute due time.
843
+ * Schedules an action to be executed at the specified absolute due time.
842
844
  * @param {Function} action Action to execute.
843
845
  * @param {Number} dueTime Absolute time at which to execute the action.
844
846
  * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
@@ -848,7 +850,7 @@
848
850
  };
849
851
 
850
852
  /**
851
- * Schedules an action to be executed at dueTime.
853
+ * Schedules an action to be executed at dueTime.
852
854
  * @param {Mixed} state State passed to the action to be executed.
853
855
  * @param {Function} action Action to be executed.
854
856
  * @param {Number}dueTime Absolute time at which to execute the action.
@@ -865,7 +867,7 @@
865
867
  * Normalizes the specified TimeSpan value to a positive value.
866
868
  * @param {Number} timeSpan The time span value to normalize.
867
869
  * @returns {Number} The specified TimeSpan value if it is zero or positive; otherwise, 0
868
- */
870
+ */
869
871
  Scheduler.normalize = function (timeSpan) {
870
872
  timeSpan < 0 && (timeSpan = 0);
871
873
  return timeSpan;
@@ -875,7 +877,7 @@
875
877
  }());
876
878
 
877
879
  var normalizeTime = Scheduler.normalize;
878
-
880
+
879
881
  (function (schedulerProto) {
880
882
  function invokeRecImmediate(scheduler, pair) {
881
883
  var state = pair.first, action = pair.second, group = new CompositeDisposable(),
@@ -940,7 +942,7 @@
940
942
  };
941
943
 
942
944
  /**
943
- * Schedules an action to be executed recursively.
945
+ * Schedules an action to be executed recursively.
944
946
  * @param {Mixed} state State passed to the action to be executed.
945
947
  * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in recursive invocation state.
946
948
  * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
@@ -950,7 +952,7 @@
950
952
  };
951
953
 
952
954
  /**
953
- * Schedules an action to be executed recursively after a specified relative due time.
955
+ * Schedules an action to be executed recursively after a specified relative due time.
954
956
  * @param {Function} action Action to execute recursively. The parameter passed to the action is used to trigger recursive scheduling of the action at the specified relative time.
955
957
  * @param {Number}dueTime Relative time after which to execute the action for the first time.
956
958
  * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
@@ -960,7 +962,7 @@
960
962
  };
961
963
 
962
964
  /**
963
- * Schedules an action to be executed recursively after a specified relative due time.
965
+ * Schedules an action to be executed recursively after a specified relative due time.
964
966
  * @param {Mixed} state State passed to the action to be executed.
965
967
  * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in the recursive due time and invocation state.
966
968
  * @param {Number}dueTime Relative time after which to execute the action for the first time.
@@ -973,7 +975,7 @@
973
975
  };
974
976
 
975
977
  /**
976
- * Schedules an action to be executed recursively at a specified absolute due time.
978
+ * Schedules an action to be executed recursively at a specified absolute due time.
977
979
  * @param {Function} action Action to execute recursively. The parameter passed to the action is used to trigger recursive scheduling of the action at the specified absolute time.
978
980
  * @param {Number}dueTime Absolute time at which to execute the action for the first time.
979
981
  * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
@@ -983,7 +985,7 @@
983
985
  };
984
986
 
985
987
  /**
986
- * Schedules an action to be executed recursively at a specified absolute due time.
988
+ * Schedules an action to be executed recursively at a specified absolute due time.
987
989
  * @param {Mixed} state State passed to the action to be executed.
988
990
  * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in the recursive due time and invocation state.
989
991
  * @param {Number}dueTime Absolute time at which to execute the action for the first time.
@@ -993,23 +995,23 @@
993
995
  return this._scheduleAbsolute({ first: state, second: action }, dueTime, function (s, p) {
994
996
  return invokeRecDate(s, p, 'scheduleWithAbsoluteAndState');
995
997
  });
996
- };
998
+ };
997
999
  }(Scheduler.prototype));
998
1000
 
999
1001
  (function (schedulerProto) {
1000
1002
 
1001
1003
  /**
1002
- * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be scheduled using window.setInterval for the base implementation.
1004
+ * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be scheduled using window.setInterval for the base implementation.
1003
1005
  * @param {Number} period Period for running the work periodically.
1004
1006
  * @param {Function} action Action to be executed.
1005
1007
  * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort).
1006
- */
1008
+ */
1007
1009
  Scheduler.prototype.schedulePeriodic = function (period, action) {
1008
1010
  return this.schedulePeriodicWithState(null, period, action);
1009
1011
  };
1010
1012
 
1011
1013
  /**
1012
- * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be scheduled using window.setInterval for the base implementation.
1014
+ * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be scheduled using window.setInterval for the base implementation.
1013
1015
  * @param {Mixed} state Initial state passed to the action upon the first iteration.
1014
1016
  * @param {Number} period Period for running the work periodically.
1015
1017
  * @param {Function} action Action to be executed, potentially updating the state.
@@ -1018,7 +1020,7 @@
1018
1020
  Scheduler.prototype.schedulePeriodicWithState = function(state, period, action) {
1019
1021
  if (typeof root.setInterval === 'undefined') { throw new Error('Periodic scheduling not supported.'); }
1020
1022
  var s = state;
1021
-
1023
+
1022
1024
  var id = root.setInterval(function () {
1023
1025
  s = action(s);
1024
1026
  }, period);
@@ -1029,68 +1031,68 @@
1029
1031
  };
1030
1032
 
1031
1033
  }(Scheduler.prototype));
1032
-
1034
+
1033
1035
  (function (schedulerProto) {
1034
1036
  /**
1035
- * Returns a scheduler that wraps the original scheduler, adding exception handling for scheduled actions.
1037
+ * Returns a scheduler that wraps the original scheduler, adding exception handling for scheduled actions.
1036
1038
  * @param {Function} handler Handler that's run if an exception is caught. The exception will be rethrown if the handler returns false.
1037
1039
  * @returns {Scheduler} Wrapper around the original scheduler, enforcing exception handling.
1038
- */
1040
+ */
1039
1041
  schedulerProto.catchError = schedulerProto['catch'] = function (handler) {
1040
1042
  return new CatchScheduler(this, handler);
1041
1043
  };
1042
- }(Scheduler.prototype));
1043
-
1044
- var SchedulePeriodicRecursive = Rx.internals.SchedulePeriodicRecursive = (function () {
1045
- function tick(command, recurse) {
1046
- recurse(0, this._period);
1047
- try {
1048
- this._state = this._action(this._state);
1049
- } catch (e) {
1050
- this._cancel.dispose();
1051
- throw e;
1052
- }
1053
- }
1054
-
1055
- function SchedulePeriodicRecursive(scheduler, state, period, action) {
1056
- this._scheduler = scheduler;
1057
- this._state = state;
1058
- this._period = period;
1059
- this._action = action;
1060
- }
1061
-
1062
- SchedulePeriodicRecursive.prototype.start = function () {
1063
- var d = new SingleAssignmentDisposable();
1064
- this._cancel = d;
1065
- d.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0, this._period, tick.bind(this)));
1066
-
1067
- return d;
1068
- };
1069
-
1070
- return SchedulePeriodicRecursive;
1071
- }());
1072
-
1073
- /**
1074
- * Gets a scheduler that schedules work immediately on the current thread.
1075
- */
1076
- var immediateScheduler = Scheduler.immediate = (function () {
1077
-
1078
- function scheduleNow(state, action) { return action(this, state); }
1079
-
1080
- function scheduleRelative(state, dueTime, action) {
1081
- var dt = normalizeTime(dt);
1082
- while (dt - this.now() > 0) { }
1083
- return action(this, state);
1084
- }
1085
-
1086
- function scheduleAbsolute(state, dueTime, action) {
1087
- return this.scheduleWithRelativeAndState(state, dueTime - this.now(), action);
1088
- }
1089
-
1090
- return new Scheduler(defaultNow, scheduleNow, scheduleRelative, scheduleAbsolute);
1091
- }());
1092
-
1093
- /**
1044
+ }(Scheduler.prototype));
1045
+
1046
+ var SchedulePeriodicRecursive = Rx.internals.SchedulePeriodicRecursive = (function () {
1047
+ function tick(command, recurse) {
1048
+ recurse(0, this._period);
1049
+ try {
1050
+ this._state = this._action(this._state);
1051
+ } catch (e) {
1052
+ this._cancel.dispose();
1053
+ throw e;
1054
+ }
1055
+ }
1056
+
1057
+ function SchedulePeriodicRecursive(scheduler, state, period, action) {
1058
+ this._scheduler = scheduler;
1059
+ this._state = state;
1060
+ this._period = period;
1061
+ this._action = action;
1062
+ }
1063
+
1064
+ SchedulePeriodicRecursive.prototype.start = function () {
1065
+ var d = new SingleAssignmentDisposable();
1066
+ this._cancel = d;
1067
+ d.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0, this._period, tick.bind(this)));
1068
+
1069
+ return d;
1070
+ };
1071
+
1072
+ return SchedulePeriodicRecursive;
1073
+ }());
1074
+
1075
+ /**
1076
+ * Gets a scheduler that schedules work immediately on the current thread.
1077
+ */
1078
+ var immediateScheduler = Scheduler.immediate = (function () {
1079
+
1080
+ function scheduleNow(state, action) { return action(this, state); }
1081
+
1082
+ function scheduleRelative(state, dueTime, action) {
1083
+ var dt = normalizeTime(dt);
1084
+ while (dt - this.now() > 0) { }
1085
+ return action(this, state);
1086
+ }
1087
+
1088
+ function scheduleAbsolute(state, dueTime, action) {
1089
+ return this.scheduleWithRelativeAndState(state, dueTime - this.now(), action);
1090
+ }
1091
+
1092
+ return new Scheduler(defaultNow, scheduleNow, scheduleRelative, scheduleAbsolute);
1093
+ }());
1094
+
1095
+ /**
1094
1096
  * Gets a scheduler that schedules work as soon as possible on the current thread.
1095
1097
  */
1096
1098
  var currentThreadScheduler = Scheduler.currentThread = (function () {
@@ -1124,7 +1126,7 @@
1124
1126
  queue.enqueue(si);
1125
1127
  try {
1126
1128
  runTrampoline(queue);
1127
- } catch (e) {
1129
+ } catch (e) {
1128
1130
  throw e;
1129
1131
  } finally {
1130
1132
  queue = null;
@@ -1140,7 +1142,7 @@
1140
1142
  }
1141
1143
 
1142
1144
  var currentScheduler = new Scheduler(defaultNow, scheduleNow, scheduleRelative, scheduleAbsolute);
1143
-
1145
+
1144
1146
  currentScheduler.scheduleRequired = function () { return !queue; };
1145
1147
  currentScheduler.ensureTrampoline = function (action) {
1146
1148
  if (!queue) { this.schedule(action); } else { action(); }
@@ -1168,11 +1170,11 @@
1168
1170
  setTimeout: localSetTimeout,
1169
1171
  clearTimeout: localClearTimeout
1170
1172
  };
1171
- }());
1173
+ }());
1172
1174
  var localSetTimeout = localTimer.setTimeout,
1173
1175
  localClearTimeout = localTimer.clearTimeout;
1174
1176
 
1175
- (function () {
1177
+ (function () {
1176
1178
 
1177
1179
  var reNative = RegExp('^' +
1178
1180
  String(toString)
@@ -1188,7 +1190,7 @@
1188
1190
  function postMessageSupported () {
1189
1191
  // Ensure not in a worker
1190
1192
  if (!root.postMessage || root.importScripts) { return false; }
1191
- var isAsync = false,
1193
+ var isAsync = false,
1192
1194
  oldHandler = root.onmessage;
1193
1195
  // Test for async
1194
1196
  root.onmessage = function () { isAsync = true; };
@@ -1245,19 +1247,19 @@
1245
1247
  scheduleMethod = function (action) {
1246
1248
  var id = channelTaskId++;
1247
1249
  channelTasks[id] = action;
1248
- channel.port2.postMessage(id);
1250
+ channel.port2.postMessage(id);
1249
1251
  };
1250
1252
  } else if ('document' in root && 'onreadystatechange' in root.document.createElement('script')) {
1251
-
1253
+
1252
1254
  scheduleMethod = function (action) {
1253
1255
  var scriptElement = root.document.createElement('script');
1254
- scriptElement.onreadystatechange = function () {
1256
+ scriptElement.onreadystatechange = function () {
1255
1257
  action();
1256
1258
  scriptElement.onreadystatechange = null;
1257
1259
  scriptElement.parentNode.removeChild(scriptElement);
1258
- scriptElement = null;
1260
+ scriptElement = null;
1259
1261
  };
1260
- root.document.documentElement.appendChild(scriptElement);
1262
+ root.document.documentElement.appendChild(scriptElement);
1261
1263
  };
1262
1264
 
1263
1265
  } else {
@@ -1266,7 +1268,7 @@
1266
1268
  }
1267
1269
  }());
1268
1270
 
1269
- /**
1271
+ /**
1270
1272
  * Gets a scheduler that schedules work via a timed callback based upon platform.
1271
1273
  */
1272
1274
  var timeoutScheduler = Scheduler.timeout = (function () {
@@ -1394,14 +1396,14 @@
1394
1396
  * Represents a notification to an observer.
1395
1397
  */
1396
1398
  var Notification = Rx.Notification = (function () {
1397
- function Notification(kind, hasValue) {
1399
+ function Notification(kind, hasValue) {
1398
1400
  this.hasValue = hasValue == null ? false : hasValue;
1399
1401
  this.kind = kind;
1400
1402
  }
1401
1403
 
1402
1404
  /**
1403
1405
  * Invokes the delegate corresponding to the notification or the observer's method corresponding to the notification and returns the produced result.
1404
- *
1406
+ *
1405
1407
  * @memberOf Notification
1406
1408
  * @param {Any} observerOrOnNext Delegate to invoke for an OnNext notification or Observer to invoke the notification on..
1407
1409
  * @param {Function} onError Delegate to invoke for an OnError notification.
@@ -1416,7 +1418,7 @@
1416
1418
 
1417
1419
  /**
1418
1420
  * Returns an observable sequence with a single notification.
1419
- *
1421
+ *
1420
1422
  * @memberOf Notifications
1421
1423
  * @param {Scheduler} [scheduler] Scheduler to send out the notification calls on.
1422
1424
  * @returns {Observable} The observable sequence that surfaces the behavior of the notification upon subscription.
@@ -1496,150 +1498,150 @@
1496
1498
  };
1497
1499
  }());
1498
1500
 
1499
- var Enumerator = Rx.internals.Enumerator = function (next) {
1500
- this._next = next;
1501
- };
1502
-
1503
- Enumerator.prototype.next = function () {
1504
- return this._next();
1505
- };
1506
-
1507
- Enumerator.prototype[$iterator$] = function () { return this; }
1508
-
1509
- var Enumerable = Rx.internals.Enumerable = function (iterator) {
1510
- this._iterator = iterator;
1511
- };
1512
-
1513
- Enumerable.prototype[$iterator$] = function () {
1514
- return this._iterator();
1515
- };
1516
-
1517
- Enumerable.prototype.concat = function () {
1518
- var sources = this;
1519
- return new AnonymousObservable(function (observer) {
1520
- var e;
1521
- try {
1522
- e = sources[$iterator$]();
1523
- } catch(err) {
1524
- observer.onError();
1525
- return;
1526
- }
1527
-
1528
- var isDisposed,
1529
- subscription = new SerialDisposable();
1530
- var cancelable = immediateScheduler.scheduleRecursive(function (self) {
1531
- var currentItem;
1532
- if (isDisposed) { return; }
1533
-
1534
- try {
1535
- currentItem = e.next();
1536
- } catch (ex) {
1537
- observer.onError(ex);
1538
- return;
1539
- }
1540
-
1541
- if (currentItem.done) {
1542
- observer.onCompleted();
1543
- return;
1544
- }
1545
-
1546
- // Check if promise
1547
- var currentValue = currentItem.value;
1548
- isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));
1549
-
1550
- var d = new SingleAssignmentDisposable();
1551
- subscription.setDisposable(d);
1552
- d.setDisposable(currentValue.subscribe(
1553
- observer.onNext.bind(observer),
1554
- observer.onError.bind(observer),
1555
- function () { self(); })
1556
- );
1557
- });
1558
-
1559
- return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {
1560
- isDisposed = true;
1561
- }));
1562
- });
1563
- };
1564
-
1565
- Enumerable.prototype.catchException = function () {
1566
- var sources = this;
1567
- return new AnonymousObservable(function (observer) {
1568
- var e;
1569
- try {
1570
- e = sources[$iterator$]();
1571
- } catch(err) {
1572
- observer.onError();
1573
- return;
1574
- }
1575
-
1576
- var isDisposed,
1577
- lastException,
1578
- subscription = new SerialDisposable();
1579
- var cancelable = immediateScheduler.scheduleRecursive(function (self) {
1580
- if (isDisposed) { return; }
1581
-
1582
- var currentItem;
1583
- try {
1584
- currentItem = e.next();
1585
- } catch (ex) {
1586
- observer.onError(ex);
1587
- return;
1588
- }
1589
-
1590
- if (currentItem.done) {
1591
- if (lastException) {
1592
- observer.onError(lastException);
1593
- } else {
1594
- observer.onCompleted();
1595
- }
1596
- return;
1597
- }
1598
-
1599
- // Check if promise
1600
- var currentValue = currentItem.value;
1601
- isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));
1602
-
1603
- var d = new SingleAssignmentDisposable();
1604
- subscription.setDisposable(d);
1605
- d.setDisposable(currentValue.subscribe(
1606
- observer.onNext.bind(observer),
1607
- function (exn) {
1608
- lastException = exn;
1609
- self();
1610
- },
1611
- observer.onCompleted.bind(observer)));
1612
- });
1613
- return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {
1614
- isDisposed = true;
1615
- }));
1616
- });
1617
- };
1618
-
1619
- var enumerableRepeat = Enumerable.repeat = function (value, repeatCount) {
1620
- if (repeatCount == null) { repeatCount = -1; }
1621
- return new Enumerable(function () {
1622
- var left = repeatCount;
1623
- return new Enumerator(function () {
1624
- if (left === 0) { return doneEnumerator; }
1625
- if (left > 0) { left--; }
1626
- return { done: false, value: value };
1627
- });
1628
- });
1629
- };
1630
-
1631
- var enumerableFor = Enumerable.forEach = function (source, selector, thisArg) {
1632
- selector || (selector = identity);
1633
- return new Enumerable(function () {
1634
- var index = -1;
1635
- return new Enumerator(
1636
- function () {
1637
- return ++index < source.length ?
1638
- { done: false, value: selector.call(thisArg, source[index], index, source) } :
1639
- doneEnumerator;
1640
- });
1641
- });
1642
- };
1501
+ var Enumerator = Rx.internals.Enumerator = function (next) {
1502
+ this._next = next;
1503
+ };
1504
+
1505
+ Enumerator.prototype.next = function () {
1506
+ return this._next();
1507
+ };
1508
+
1509
+ Enumerator.prototype[$iterator$] = function () { return this; }
1510
+
1511
+ var Enumerable = Rx.internals.Enumerable = function (iterator) {
1512
+ this._iterator = iterator;
1513
+ };
1514
+
1515
+ Enumerable.prototype[$iterator$] = function () {
1516
+ return this._iterator();
1517
+ };
1518
+
1519
+ Enumerable.prototype.concat = function () {
1520
+ var sources = this;
1521
+ return new AnonymousObservable(function (observer) {
1522
+ var e;
1523
+ try {
1524
+ e = sources[$iterator$]();
1525
+ } catch(err) {
1526
+ observer.onError();
1527
+ return;
1528
+ }
1529
+
1530
+ var isDisposed,
1531
+ subscription = new SerialDisposable();
1532
+ var cancelable = immediateScheduler.scheduleRecursive(function (self) {
1533
+ var currentItem;
1534
+ if (isDisposed) { return; }
1535
+
1536
+ try {
1537
+ currentItem = e.next();
1538
+ } catch (ex) {
1539
+ observer.onError(ex);
1540
+ return;
1541
+ }
1542
+
1543
+ if (currentItem.done) {
1544
+ observer.onCompleted();
1545
+ return;
1546
+ }
1547
+
1548
+ // Check if promise
1549
+ var currentValue = currentItem.value;
1550
+ isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));
1551
+
1552
+ var d = new SingleAssignmentDisposable();
1553
+ subscription.setDisposable(d);
1554
+ d.setDisposable(currentValue.subscribe(
1555
+ observer.onNext.bind(observer),
1556
+ observer.onError.bind(observer),
1557
+ function () { self(); })
1558
+ );
1559
+ });
1560
+
1561
+ return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {
1562
+ isDisposed = true;
1563
+ }));
1564
+ });
1565
+ };
1566
+
1567
+ Enumerable.prototype.catchException = function () {
1568
+ var sources = this;
1569
+ return new AnonymousObservable(function (observer) {
1570
+ var e;
1571
+ try {
1572
+ e = sources[$iterator$]();
1573
+ } catch(err) {
1574
+ observer.onError();
1575
+ return;
1576
+ }
1577
+
1578
+ var isDisposed,
1579
+ lastException,
1580
+ subscription = new SerialDisposable();
1581
+ var cancelable = immediateScheduler.scheduleRecursive(function (self) {
1582
+ if (isDisposed) { return; }
1583
+
1584
+ var currentItem;
1585
+ try {
1586
+ currentItem = e.next();
1587
+ } catch (ex) {
1588
+ observer.onError(ex);
1589
+ return;
1590
+ }
1591
+
1592
+ if (currentItem.done) {
1593
+ if (lastException) {
1594
+ observer.onError(lastException);
1595
+ } else {
1596
+ observer.onCompleted();
1597
+ }
1598
+ return;
1599
+ }
1600
+
1601
+ // Check if promise
1602
+ var currentValue = currentItem.value;
1603
+ isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));
1604
+
1605
+ var d = new SingleAssignmentDisposable();
1606
+ subscription.setDisposable(d);
1607
+ d.setDisposable(currentValue.subscribe(
1608
+ observer.onNext.bind(observer),
1609
+ function (exn) {
1610
+ lastException = exn;
1611
+ self();
1612
+ },
1613
+ observer.onCompleted.bind(observer)));
1614
+ });
1615
+ return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {
1616
+ isDisposed = true;
1617
+ }));
1618
+ });
1619
+ };
1620
+
1621
+ var enumerableRepeat = Enumerable.repeat = function (value, repeatCount) {
1622
+ if (repeatCount == null) { repeatCount = -1; }
1623
+ return new Enumerable(function () {
1624
+ var left = repeatCount;
1625
+ return new Enumerator(function () {
1626
+ if (left === 0) { return doneEnumerator; }
1627
+ if (left > 0) { left--; }
1628
+ return { done: false, value: value };
1629
+ });
1630
+ });
1631
+ };
1632
+
1633
+ var enumerableOf = Enumerable.of = function (source, selector, thisArg) {
1634
+ selector || (selector = identity);
1635
+ return new Enumerable(function () {
1636
+ var index = -1;
1637
+ return new Enumerator(
1638
+ function () {
1639
+ return ++index < source.length ?
1640
+ { done: false, value: selector.call(thisArg, source[index], index, source) } :
1641
+ doneEnumerator;
1642
+ });
1643
+ });
1644
+ };
1643
1645
 
1644
1646
  /**
1645
1647
  * Supports push-style iteration over an observable sequence.
@@ -1648,22 +1650,17 @@
1648
1650
 
1649
1651
  /**
1650
1652
  * Creates a notification callback from an observer.
1651
- *
1652
- * @param observer Observer object.
1653
1653
  * @returns The action that forwards its input notification to the underlying observer.
1654
1654
  */
1655
1655
  Observer.prototype.toNotifier = function () {
1656
1656
  var observer = this;
1657
- return function (n) {
1658
- return n.accept(observer);
1659
- };
1657
+ return function (n) { return n.accept(observer); };
1660
1658
  };
1661
1659
 
1662
1660
  /**
1663
1661
  * Hides the identity of an observer.
1664
-
1665
- * @returns An observer that hides the identity of the specified observer.
1666
- */
1662
+ * @returns An observer that hides the identity of the specified observer.
1663
+ */
1667
1664
  Observer.prototype.asObserver = function () {
1668
1665
  return new AnonymousObserver(this.onNext.bind(this), this.onError.bind(this), this.onCompleted.bind(this));
1669
1666
  };
@@ -1671,16 +1668,12 @@
1671
1668
  /**
1672
1669
  * 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.
1673
1670
  * If a violation is detected, an Error is thrown from the offending observer method call.
1674
- *
1675
1671
  * @returns An observer that checks callbacks invocations against the observer grammar and, if the checks pass, forwards those to the specified observer.
1676
- */
1672
+ */
1677
1673
  Observer.prototype.checked = function () { return new CheckedObserver(this); };
1678
1674
 
1679
1675
  /**
1680
1676
  * Creates an observer from the specified OnNext, along with optional OnError, and OnCompleted actions.
1681
- *
1682
- * @static
1683
- * @memberOf Observer
1684
1677
  * @param {Function} [onNext] Observer's OnNext action implementation.
1685
1678
  * @param {Function} [onError] Observer's OnError action implementation.
1686
1679
  * @param {Function} [onCompleted] Observer's OnCompleted action implementation.
@@ -1695,19 +1688,19 @@
1695
1688
 
1696
1689
  /**
1697
1690
  * Creates an observer from a notification callback.
1698
- *
1691
+ *
1699
1692
  * @static
1700
1693
  * @memberOf Observer
1701
1694
  * @param {Function} handler Action that handles a notification.
1702
1695
  * @returns The observer object that invokes the specified handler using a notification corresponding to each message it receives.
1703
1696
  */
1704
- Observer.fromNotifier = function (handler) {
1697
+ Observer.fromNotifier = function (handler, thisArg) {
1705
1698
  return new AnonymousObserver(function (x) {
1706
- return handler(notificationCreateOnNext(x));
1707
- }, function (exception) {
1708
- return handler(notificationCreateOnError(exception));
1699
+ return handler.call(thisArg, notificationCreateOnNext(x));
1700
+ }, function (e) {
1701
+ return handler.call(thisArg, notificationCreateOnError(e));
1709
1702
  }, function () {
1710
- return handler(notificationCreateOnCompleted());
1703
+ return handler.call(thisArg, notificationCreateOnCompleted());
1711
1704
  });
1712
1705
  };
1713
1706
 
@@ -1719,93 +1712,85 @@
1719
1712
  Observer.notifyOn = function (scheduler) {
1720
1713
  return new ObserveOnObserver(scheduler, this);
1721
1714
  };
1722
-
1715
+
1716
+ /**
1717
+ * Abstract base class for implementations of the Observer class.
1718
+ * This base class enforces the grammar of observers where OnError and OnCompleted are terminal messages.
1719
+ */
1720
+ var AbstractObserver = Rx.internals.AbstractObserver = (function (__super__) {
1721
+ inherits(AbstractObserver, __super__);
1722
+
1723
1723
  /**
1724
- * Abstract base class for implementations of the Observer class.
1725
- * This base class enforces the grammar of observers where OnError and OnCompleted are terminal messages.
1724
+ * Creates a new observer in a non-stopped state.
1726
1725
  */
1727
- var AbstractObserver = Rx.internals.AbstractObserver = (function (_super) {
1728
- inherits(AbstractObserver, _super);
1729
-
1730
- /**
1731
- * Creates a new observer in a non-stopped state.
1732
- *
1733
- * @constructor
1734
- */
1735
- function AbstractObserver() {
1736
- this.isStopped = false;
1737
- _super.call(this);
1738
- }
1726
+ function AbstractObserver() {
1727
+ this.isStopped = false;
1728
+ __super__.call(this);
1729
+ }
1739
1730
 
1740
- /**
1741
- * Notifies the observer of a new element in the sequence.
1742
- *
1743
- * @memberOf AbstractObserver
1744
- * @param {Any} value Next element in the sequence.
1745
- */
1746
- AbstractObserver.prototype.onNext = function (value) {
1747
- if (!this.isStopped) {
1748
- this.next(value);
1749
- }
1750
- };
1731
+ /**
1732
+ * Notifies the observer of a new element in the sequence.
1733
+ * @param {Any} value Next element in the sequence.
1734
+ */
1735
+ AbstractObserver.prototype.onNext = function (value) {
1736
+ if (!this.isStopped) { this.next(value); }
1737
+ };
1751
1738
 
1752
- /**
1753
- * Notifies the observer that an exception has occurred.
1754
- *
1755
- * @memberOf AbstractObserver
1756
- * @param {Any} error The error that has occurred.
1757
- */
1758
- AbstractObserver.prototype.onError = function (error) {
1759
- if (!this.isStopped) {
1760
- this.isStopped = true;
1761
- this.error(error);
1762
- }
1763
- };
1739
+ /**
1740
+ * Notifies the observer that an exception has occurred.
1741
+ * @param {Any} error The error that has occurred.
1742
+ */
1743
+ AbstractObserver.prototype.onError = function (error) {
1744
+ if (!this.isStopped) {
1745
+ this.isStopped = true;
1746
+ this.error(error);
1747
+ }
1748
+ };
1764
1749
 
1765
- /**
1766
- * Notifies the observer of the end of the sequence.
1767
- */
1768
- AbstractObserver.prototype.onCompleted = function () {
1769
- if (!this.isStopped) {
1770
- this.isStopped = true;
1771
- this.completed();
1772
- }
1773
- };
1750
+ /**
1751
+ * Notifies the observer of the end of the sequence.
1752
+ */
1753
+ AbstractObserver.prototype.onCompleted = function () {
1754
+ if (!this.isStopped) {
1755
+ this.isStopped = true;
1756
+ this.completed();
1757
+ }
1758
+ };
1774
1759
 
1775
- /**
1776
- * Disposes the observer, causing it to transition to the stopped state.
1777
- */
1778
- AbstractObserver.prototype.dispose = function () {
1779
- this.isStopped = true;
1780
- };
1760
+ /**
1761
+ * Disposes the observer, causing it to transition to the stopped state.
1762
+ */
1763
+ AbstractObserver.prototype.dispose = function () {
1764
+ this.isStopped = true;
1765
+ };
1781
1766
 
1782
- AbstractObserver.prototype.fail = function (e) {
1783
- if (!this.isStopped) {
1784
- this.isStopped = true;
1785
- this.error(e);
1786
- return true;
1787
- }
1767
+ AbstractObserver.prototype.fail = function (e) {
1768
+ if (!this.isStopped) {
1769
+ this.isStopped = true;
1770
+ this.error(e);
1771
+ return true;
1772
+ }
1788
1773
 
1789
- return false;
1790
- };
1774
+ return false;
1775
+ };
1791
1776
 
1792
- return AbstractObserver;
1793
- }(Observer));
1777
+ return AbstractObserver;
1778
+ }(Observer));
1794
1779
 
1795
1780
  /**
1796
1781
  * Class to create an Observer instance from delegate-based implementations of the on* methods.
1797
1782
  */
1798
- var AnonymousObserver = Rx.AnonymousObserver = (function (_super) {
1799
- inherits(AnonymousObserver, _super);
1783
+ var AnonymousObserver = Rx.AnonymousObserver = (function (__super__) {
1784
+ inherits(AnonymousObserver, __super__);
1800
1785
 
1801
1786
  /**
1802
1787
  * Creates an observer from the specified OnNext, OnError, and OnCompleted actions.
1803
1788
  * @param {Any} onNext Observer's OnNext action implementation.
1804
1789
  * @param {Any} onError Observer's OnError action implementation.
1805
- * @param {Any} onCompleted Observer's OnCompleted action implementation.
1806
- */
1790
+ * @param {Any} onCompleted Observer's OnCompleted action implementation.
1791
+ */
1807
1792
  function AnonymousObserver(onNext, onError, onCompleted) {
1808
- _super.call(this);
1793
+ __super__.call(this);
1809
1794
  this._onNext = onNext;
1810
1795
  this._onError = onError;
1811
1796
  this._onCompleted = onCompleted;
@@ -1813,23 +1798,23 @@
1813
1798
 
1814
1799
  /**
1815
1800
  * Calls the onNext action.
1816
- * @param {Any} value Next element in the sequence.
1817
- */
1801
+ * @param {Any} value Next element in the sequence.
1802
+ */
1818
1803
  AnonymousObserver.prototype.next = function (value) {
1819
1804
  this._onNext(value);
1820
1805
  };
1821
1806
 
1822
1807
  /**
1823
1808
  * Calls the onError action.
1824
- * @param {Any} error The error that has occurred.
1825
- */
1826
- AnonymousObserver.prototype.error = function (exception) {
1827
- this._onError(exception);
1809
+ * @param {Any} error The error that has occurred.
1810
+ */
1811
+ AnonymousObserver.prototype.error = function (error) {
1812
+ this._onError(error);
1828
1813
  };
1829
1814
 
1830
1815
  /**
1831
1816
  * Calls the onCompleted action.
1832
- */
1817
+ */
1833
1818
  AnonymousObserver.prototype.completed = function () {
1834
1819
  this._onCompleted();
1835
1820
  };
@@ -1852,8 +1837,8 @@
1852
1837
  this.checkAccess();
1853
1838
  try {
1854
1839
  this._observer.onNext(value);
1855
- } catch (e) {
1856
- throw e;
1840
+ } catch (e) {
1841
+ throw e;
1857
1842
  } finally {
1858
1843
  this._state = 0;
1859
1844
  }
@@ -1863,8 +1848,8 @@
1863
1848
  this.checkAccess();
1864
1849
  try {
1865
1850
  this._observer.onError(err);
1866
- } catch (e) {
1867
- throw e;
1851
+ } catch (e) {
1852
+ throw e;
1868
1853
  } finally {
1869
1854
  this._state = 2;
1870
1855
  }
@@ -1874,8 +1859,8 @@
1874
1859
  this.checkAccess();
1875
1860
  try {
1876
1861
  this._observer.onCompleted();
1877
- } catch (e) {
1878
- throw e;
1862
+ } catch (e) {
1863
+ throw e;
1879
1864
  } finally {
1880
1865
  this._state = 2;
1881
1866
  }
@@ -1999,24 +1984,45 @@
1999
1984
 
2000
1985
  /**
2001
1986
  * Subscribes an observer to the observable sequence.
2002
- *
2003
- * @example
2004
- * 1 - source.subscribe();
2005
- * 2 - source.subscribe(observer);
2006
- * 3 - source.subscribe(function (x) { console.log(x); });
2007
- * 4 - source.subscribe(function (x) { console.log(x); }, function (err) { console.log(err); });
2008
- * 5 - source.subscribe(function (x) { console.log(x); }, function (err) { console.log(err); }, function () { console.log('done'); });
2009
1987
  * @param {Mixed} [observerOrOnNext] The object that is to receive notifications or an action to invoke for each element in the observable sequence.
2010
1988
  * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence.
2011
1989
  * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence.
2012
- * @returns {Diposable} The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler.
1990
+ * @returns {Diposable} A disposable handling the subscriptions and unsubscriptions.
2013
1991
  */
2014
1992
  observableProto.subscribe = observableProto.forEach = function (observerOrOnNext, onError, onCompleted) {
2015
- var subscriber = typeof observerOrOnNext === 'object' ?
1993
+ return this._subscribe(typeof observerOrOnNext === 'object' ?
2016
1994
  observerOrOnNext :
2017
- observerCreate(observerOrOnNext, onError, onCompleted);
1995
+ observerCreate(observerOrOnNext, onError, onCompleted));
1996
+ };
2018
1997
 
2019
- return this._subscribe(subscriber);
1998
+ /**
1999
+ * Subscribes to the next value in the sequence with an optional "this" argument.
2000
+ * @param {Function} onNext The function to invoke on each element in the observable sequence.
2001
+ * @param {Any} [thisArg] Object to use as this when executing callback.
2002
+ * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.
2003
+ */
2004
+ observableProto.subscribeOnNext = function (onNext, thisArg) {
2005
+ return this._subscribe(observerCreate(arguments.length === 2 ? function(x) { onNext.call(thisArg, x); } : onNext));
2006
+ };
2007
+
2008
+ /**
2009
+ * Subscribes to an exceptional condition in the sequence with an optional "this" argument.
2010
+ * @param {Function} onError The function to invoke upon exceptional termination of the observable sequence.
2011
+ * @param {Any} [thisArg] Object to use as this when executing callback.
2012
+ * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.
2013
+ */
2014
+ observableProto.subscribeOnError = function (onError, thisArg) {
2015
+ return this._subscribe(observerCreate(null, arguments.length === 2 ? function(e) { onError.call(thisArg, e); } : onError));
2016
+ };
2017
+
2018
+ /**
2019
+ * Subscribes to the next value in the sequence with an optional "this" argument.
2020
+ * @param {Function} onCompleted The function to invoke upon graceful termination of the observable sequence.
2021
+ * @param {Any} [thisArg] Object to use as this when executing callback.
2022
+ * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.
2023
+ */
2024
+ observableProto.subscribeOnCompleted = function (onCompleted, thisArg) {
2025
+ return this._subscribe(observerCreate(null, null, arguments.length === 2 ? function() { onCompleted.call(thisArg); } : onCompleted));
2020
2026
  };
2021
2027
 
2022
2028
  return Observable;
@@ -2024,12 +2030,12 @@
2024
2030
 
2025
2031
  /**
2026
2032
  * Wraps the source sequence in order to run its observer callbacks on the specified scheduler.
2027
- *
2033
+ *
2028
2034
  * This only invokes observer callbacks on a scheduler. In case the subscription and/or unsubscription actions have side-effects
2029
2035
  * that require to be run on a scheduler, use subscribeOn.
2030
- *
2036
+ *
2031
2037
  * @param {Scheduler} scheduler Scheduler to notify observers on.
2032
- * @returns {Observable} The source sequence whose observations happen on the specified scheduler.
2038
+ * @returns {Observable} The source sequence whose observations happen on the specified scheduler.
2033
2039
  */
2034
2040
  observableProto.observeOn = function (scheduler) {
2035
2041
  var source = this;
@@ -2081,11 +2087,12 @@
2081
2087
  return subject;
2082
2088
  });
2083
2089
  };
2090
+
2084
2091
  /*
2085
2092
  * Converts an existing observable sequence to an ES6 Compatible Promise
2086
2093
  * @example
2087
2094
  * var promise = Rx.Observable.return(42).toPromise(RSVP.Promise);
2088
- *
2095
+ *
2089
2096
  * // With config
2090
2097
  * Rx.config.Promise = RSVP.Promise;
2091
2098
  * var promise = Rx.Observable.return(42).toPromise();
@@ -2107,9 +2114,10 @@
2107
2114
  });
2108
2115
  });
2109
2116
  };
2117
+
2110
2118
  /**
2111
2119
  * Creates a list from an observable sequence.
2112
- * @returns An observable sequence containing a single element with a list containing all the elements of the source sequence.
2120
+ * @returns An observable sequence containing a single element with a list containing all the elements of the source sequence.
2113
2121
  */
2114
2122
  observableProto.toArray = function () {
2115
2123
  var self = this;
@@ -2127,12 +2135,12 @@
2127
2135
 
2128
2136
  /**
2129
2137
  * Creates an observable sequence from a specified subscribe method implementation.
2130
- *
2138
+ *
2131
2139
  * @example
2132
2140
  * var res = Rx.Observable.create(function (observer) { return function () { } );
2133
- * var res = Rx.Observable.create(function (observer) { return Rx.Disposable.empty; } );
2134
- * var res = Rx.Observable.create(function (observer) { } );
2135
- *
2141
+ * var res = Rx.Observable.create(function (observer) { return Rx.Disposable.empty; } );
2142
+ * var res = Rx.Observable.create(function (observer) { } );
2143
+ *
2136
2144
  * @param {Function} subscribe Implementation of the resulting observable sequence's subscribe method, returning a function that will be wrapped in a Disposable.
2137
2145
  * @returns {Observable} The observable sequence with the specified implementation for the Subscribe method.
2138
2146
  */
@@ -2142,9 +2150,9 @@
2142
2150
 
2143
2151
  /**
2144
2152
  * Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes.
2145
- *
2153
+ *
2146
2154
  * @example
2147
- * var res = Rx.Observable.defer(function () { return Rx.Observable.fromArray([1,2,3]); });
2155
+ * var res = Rx.Observable.defer(function () { return Rx.Observable.fromArray([1,2,3]); });
2148
2156
  * @param {Function} observableFactory Observable factory function to invoke for each observer that subscribes to the resulting sequence or Promise.
2149
2157
  * @returns {Observable} An observable sequence whose observers trigger an invocation of the given observable factory function.
2150
2158
  */
@@ -2163,10 +2171,10 @@
2163
2171
 
2164
2172
  /**
2165
2173
  * Returns an empty observable sequence, using the specified scheduler to send out the single OnCompleted message.
2166
- *
2174
+ *
2167
2175
  * @example
2168
- * var res = Rx.Observable.empty();
2169
- * var res = Rx.Observable.empty(Rx.Scheduler.timeout);
2176
+ * var res = Rx.Observable.empty();
2177
+ * var res = Rx.Observable.empty(Rx.Scheduler.timeout);
2170
2178
  * @param {Scheduler} [scheduler] Scheduler to send the termination call on.
2171
2179
  * @returns {Observable} An observable sequence with no elements.
2172
2180
  */
@@ -2204,7 +2212,7 @@
2204
2212
  var len = +o.length;
2205
2213
  if (isNaN(len)) { return 0; }
2206
2214
  if (len === 0 || !numberIsFinite(len)) { return len; }
2207
- len = sign(len) * Math.floor(Math.abs(len));
2215
+ len = sign(len) * Math.floor(Math.abs(len));
2208
2216
  if (len <= 0) { return 0; }
2209
2217
  if (len > maxSafeInteger) { return maxSafeInteger; }
2210
2218
  return len;
@@ -2256,7 +2264,7 @@
2256
2264
  } catch (e) {
2257
2265
  observer.onError(e);
2258
2266
  return;
2259
- }
2267
+ }
2260
2268
  }
2261
2269
 
2262
2270
  observer.onNext(result);
@@ -2268,9 +2276,10 @@
2268
2276
  });
2269
2277
  });
2270
2278
  };
2279
+
2271
2280
  /**
2272
2281
  * Converts an array to an observable sequence, using an optional scheduler to enumerate the array.
2273
- *
2282
+ *
2274
2283
  * @example
2275
2284
  * var res = Rx.Observable.fromArray([1,2,3]);
2276
2285
  * var res = Rx.Observable.fromArray([1,2,3], Rx.Scheduler.timeout);
@@ -2294,7 +2303,7 @@
2294
2303
 
2295
2304
  /**
2296
2305
  * Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler to send out observer messages.
2297
- *
2306
+ *
2298
2307
  * @example
2299
2308
  * var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; });
2300
2309
  * var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; }, Rx.Scheduler.timeout);
@@ -2358,7 +2367,7 @@
2358
2367
  };
2359
2368
 
2360
2369
  /**
2361
- * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.
2370
+ * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.
2362
2371
  * @example
2363
2372
  * var res = Rx.Observable.of(1,2,3);
2364
2373
  * @param {Scheduler} scheduler A scheduler to use for scheduling the arguments.
@@ -2372,7 +2381,7 @@
2372
2381
 
2373
2382
  /**
2374
2383
  * Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to send out observer messages.
2375
- *
2384
+ *
2376
2385
  * @example
2377
2386
  * var res = Rx.Observable.range(0, 10);
2378
2387
  * var res = Rx.Observable.range(0, 10, Rx.Scheduler.timeout);
@@ -2397,7 +2406,7 @@
2397
2406
 
2398
2407
  /**
2399
2408
  * Generates an observable sequence that repeats the given element the specified number of times, using the specified scheduler to send out observer messages.
2400
- *
2409
+ *
2401
2410
  * @example
2402
2411
  * var res = Rx.Observable.repeat(42);
2403
2412
  * var res = Rx.Observable.repeat(42, 4);
@@ -2416,7 +2425,7 @@
2416
2425
  /**
2417
2426
  * Returns an observable sequence that contains a single element, using the specified scheduler to send out observer messages.
2418
2427
  * There is an alias called 'just', and 'returnValue' for browsers <IE9.
2419
- *
2428
+ *
2420
2429
  * @example
2421
2430
  * var res = Rx.Observable.return(42);
2422
2431
  * var res = Rx.Observable.return(42, Rx.Scheduler.timeout);
@@ -2474,7 +2483,7 @@
2474
2483
  * Propagates the observable sequence or Promise that reacts first.
2475
2484
  * @param {Observable} rightSource Second observable sequence or Promise.
2476
2485
  * @returns {Observable} {Observable} An observable sequence that surfaces either of the given sequences, whichever reacted first.
2477
- */
2486
+ */
2478
2487
  observableProto.amb = function (rightSource) {
2479
2488
  var leftSource = this;
2480
2489
  return new AnonymousObservable(function (observer) {
@@ -2543,7 +2552,7 @@
2543
2552
  * @example
2544
2553
  * var = Rx.Observable.amb(xs, ys, zs);
2545
2554
  * @returns {Observable} An observable sequence that surfaces any of the given sequences, whichever reacted first.
2546
- */
2555
+ */
2547
2556
  Observable.amb = function () {
2548
2557
  var acc = observableNever(),
2549
2558
  items = argsOrArray(arguments, 0);
@@ -2574,7 +2583,7 @@
2574
2583
  subscription.setDisposable(d);
2575
2584
  d.setDisposable(result.subscribe(observer));
2576
2585
  }, observer.onCompleted.bind(observer)));
2577
-
2586
+
2578
2587
  return subscription;
2579
2588
  });
2580
2589
  }
@@ -2586,25 +2595,21 @@
2586
2595
  * 2 - xs.catchException(function (ex) { return ys(ex); })
2587
2596
  * @param {Mixed} handlerOrSecond Exception handler function that returns an observable sequence given the error that occurred in the first sequence, or a second observable sequence used to produce results when an error occurred in the first sequence.
2588
2597
  * @returns {Observable} An observable sequence containing the first sequence's elements, followed by the elements of the handler sequence in case an exception occurred.
2589
- */
2590
- observableProto['catch'] = observableProto.catchException = function (handlerOrSecond) {
2598
+ */
2599
+ observableProto['catch'] = observableProto.catchError = observableProto.catchException = function (handlerOrSecond) {
2591
2600
  return typeof handlerOrSecond === 'function' ?
2592
2601
  observableCatchHandler(this, handlerOrSecond) :
2593
2602
  observableCatch([this, handlerOrSecond]);
2594
2603
  };
2595
2604
 
2596
- /**
2597
- * Continues an observable sequence that is terminated by an exception with the next observable sequence.
2598
- *
2599
- * @example
2600
- * 1 - res = Rx.Observable.catchException(xs, ys, zs);
2601
- * 2 - res = Rx.Observable.catchException([xs, ys, zs]);
2602
- * @returns {Observable} An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.
2603
- */
2604
- var observableCatch = Observable.catchException = Observable['catch'] = function () {
2605
- var items = argsOrArray(arguments, 0);
2606
- return enumerableFor(items).catchException();
2607
- };
2605
+ /**
2606
+ * Continues an observable sequence that is terminated by an exception with the next observable sequence.
2607
+ * @param {Array | Arguments} args Arguments or an array to use as the next sequence if an error occurs.
2608
+ * @returns {Observable} An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.
2609
+ */
2610
+ var observableCatch = Observable.catchException = Observable.catchError = Observable['catch'] = function () {
2611
+ return enumerableOf(argsOrArray(arguments, 0)).catchException();
2612
+ };
2608
2613
 
2609
2614
  /**
2610
2615
  * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.
@@ -2613,7 +2618,7 @@
2613
2618
  * @example
2614
2619
  * 1 - obs = observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
2615
2620
  * 2 - obs = observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
2616
- * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
2621
+ * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
2617
2622
  */
2618
2623
  observableProto.combineLatest = function () {
2619
2624
  var args = slice.call(arguments);
@@ -2627,15 +2632,15 @@
2627
2632
 
2628
2633
  /**
2629
2634
  * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.
2630
- *
2635
+ *
2631
2636
  * @example
2632
2637
  * 1 - obs = Rx.Observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
2633
- * 2 - obs = Rx.Observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
2638
+ * 2 - obs = Rx.Observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
2634
2639
  * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
2635
2640
  */
2636
2641
  var combineLatest = Observable.combineLatest = function () {
2637
2642
  var args = slice.call(arguments), resultSelector = args.pop();
2638
-
2643
+
2639
2644
  if (Array.isArray(args[0])) {
2640
2645
  args = args[0];
2641
2646
  }
@@ -2692,35 +2697,31 @@
2692
2697
 
2693
2698
  /**
2694
2699
  * Concatenates all the observable sequences. This takes in either an array or variable arguments to concatenate.
2695
- *
2700
+ *
2696
2701
  * @example
2697
2702
  * 1 - concatenated = xs.concat(ys, zs);
2698
2703
  * 2 - concatenated = xs.concat([ys, zs]);
2699
- * @returns {Observable} An observable sequence that contains the elements of each given sequence, in sequential order.
2700
- */
2704
+ * @returns {Observable} An observable sequence that contains the elements of each given sequence, in sequential order.
2705
+ */
2701
2706
  observableProto.concat = function () {
2702
2707
  var items = slice.call(arguments, 0);
2703
2708
  items.unshift(this);
2704
2709
  return observableConcat.apply(this, items);
2705
2710
  };
2706
2711
 
2707
- /**
2708
- * Concatenates all the observable sequences.
2709
- *
2710
- * @example
2711
- * 1 - res = Rx.Observable.concat(xs, ys, zs);
2712
- * 2 - res = Rx.Observable.concat([xs, ys, zs]);
2713
- * @returns {Observable} An observable sequence that contains the elements of each given sequence, in sequential order.
2714
- */
2715
- var observableConcat = Observable.concat = function () {
2716
- var sources = argsOrArray(arguments, 0);
2717
- return enumerableFor(sources).concat();
2718
- };
2712
+ /**
2713
+ * Concatenates all the observable sequences.
2714
+ * @param {Array | Arguments} args Arguments or an array to concat to the observable sequence.
2715
+ * @returns {Observable} An observable sequence that contains the elements of each given sequence, in sequential order.
2716
+ */
2717
+ var observableConcat = Observable.concat = function () {
2718
+ return enumerableOf(argsOrArray(arguments, 0)).concat();
2719
+ };
2719
2720
 
2720
2721
  /**
2721
2722
  * Concatenates an observable sequence of observable sequences.
2722
- * @returns {Observable} An observable sequence that contains the elements of each observed inner sequence, in sequential order.
2723
- */
2723
+ * @returns {Observable} An observable sequence that contains the elements of each observed inner sequence, in sequential order.
2724
+ */
2724
2725
  observableProto.concatObservable = observableProto.concatAll =function () {
2725
2726
  return this.merge(1);
2726
2727
  };
@@ -2728,13 +2729,13 @@
2728
2729
  /**
2729
2730
  * Merges an observable sequence of observable sequences into an observable sequence, limiting the number of concurrent subscriptions to inner sequences.
2730
2731
  * Or merges two observable sequences into a single observable sequence.
2731
- *
2732
+ *
2732
2733
  * @example
2733
2734
  * 1 - merged = sources.merge(1);
2734
- * 2 - merged = source.merge(otherSource);
2735
+ * 2 - merged = source.merge(otherSource);
2735
2736
  * @param {Mixed} [maxConcurrentOrOther] Maximum number of inner observable sequences being subscribed to concurrently or the second observable sequence.
2736
- * @returns {Observable} The observable sequence that merges the elements of the inner sequences.
2737
- */
2737
+ * @returns {Observable} The observable sequence that merges the elements of the inner sequences.
2738
+ */
2738
2739
  observableProto.merge = function (maxConcurrentOrOther) {
2739
2740
  if (typeof maxConcurrentOrOther !== 'number') { return observableMerge(this, maxConcurrentOrOther); }
2740
2741
  var sources = this;
@@ -2774,16 +2775,16 @@
2774
2775
  };
2775
2776
 
2776
2777
  /**
2777
- * Merges all the observable sequences into a single observable sequence.
2778
+ * Merges all the observable sequences into a single observable sequence.
2778
2779
  * The scheduler is optional and if not specified, the immediate scheduler is used.
2779
- *
2780
+ *
2780
2781
  * @example
2781
2782
  * 1 - merged = Rx.Observable.merge(xs, ys, zs);
2782
2783
  * 2 - merged = Rx.Observable.merge([xs, ys, zs]);
2783
2784
  * 3 - merged = Rx.Observable.merge(scheduler, xs, ys, zs);
2784
- * 4 - merged = Rx.Observable.merge(scheduler, [xs, ys, zs]);
2785
- * @returns {Observable} The observable sequence that merges the elements of the observable sequences.
2786
- */
2785
+ * 4 - merged = Rx.Observable.merge(scheduler, [xs, ys, zs]);
2786
+ * @returns {Observable} The observable sequence that merges the elements of the observable sequences.
2787
+ */
2787
2788
  var observableMerge = Observable.merge = function () {
2788
2789
  var scheduler, sources;
2789
2790
  if (!arguments[0]) {
@@ -2800,13 +2801,13 @@
2800
2801
  sources = sources[0];
2801
2802
  }
2802
2803
  return observableFromArray(sources, scheduler).mergeObservable();
2803
- };
2804
+ };
2804
2805
 
2805
2806
  /**
2806
2807
  * Merges an observable sequence of observable sequences into an observable sequence.
2807
- * @returns {Observable} The observable sequence that merges the elements of the inner sequences.
2808
- */
2809
- observableProto.mergeObservable = observableProto.mergeAll =function () {
2808
+ * @returns {Observable} The observable sequence that merges the elements of the inner sequences.
2809
+ */
2810
+ observableProto.mergeObservable = observableProto.mergeAll = function () {
2810
2811
  var sources = this;
2811
2812
  return new AnonymousObservable(function (observer) {
2812
2813
  var group = new CompositeDisposable(),
@@ -2845,11 +2846,11 @@
2845
2846
 
2846
2847
  /**
2847
2848
  * Continues an observable sequence that is terminated normally or by an exception with the next observable sequence.
2848
- *
2849
+ *
2849
2850
  * @example
2850
2851
  * 1 - res = Rx.Observable.onErrorResumeNext(xs, ys, zs);
2851
2852
  * 1 - res = Rx.Observable.onErrorResumeNext([xs, ys, zs]);
2852
- * @returns {Observable} An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.
2853
+ * @returns {Observable} An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.
2853
2854
  */
2854
2855
  var onErrorResumeNext = Observable.onErrorResumeNext = function () {
2855
2856
  var sources = argsOrArray(arguments, 0);
@@ -2874,7 +2875,7 @@
2874
2875
  /**
2875
2876
  * Returns the values from the source observable sequence only after the other observable sequence produces a value.
2876
2877
  * @param {Observable | Promise} other The observable sequence or Promise that triggers propagation of elements of the source sequence.
2877
- * @returns {Observable} An observable sequence containing the elements of the source sequence starting from the point the other sequence triggered propagation.
2878
+ * @returns {Observable} An observable sequence containing the elements of the source sequence starting from the point the other sequence triggered propagation.
2878
2879
  */
2879
2880
  observableProto.skipUntil = function (other) {
2880
2881
  var source = this;
@@ -2903,7 +2904,7 @@
2903
2904
 
2904
2905
  /**
2905
2906
  * Transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
2906
- * @returns {Observable} The observable sequence that at any point in time produces the elements of the most recent inner observable sequence that has been received.
2907
+ * @returns {Observable} The observable sequence that at any point in time produces the elements of the most recent inner observable sequence that has been received.
2907
2908
  */
2908
2909
  observableProto['switch'] = observableProto.switchLatest = function () {
2909
2910
  var sources = this;
@@ -2922,16 +2923,16 @@
2922
2923
  isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
2923
2924
 
2924
2925
  d.setDisposable(innerSource.subscribe(
2925
- function (x) { latest === id && observer.onNext(x); },
2926
- function (e) { latest === id && observer.onError(e); },
2926
+ function (x) { latest === id && observer.onNext(x); },
2927
+ function (e) { latest === id && observer.onError(e); },
2927
2928
  function () {
2928
2929
  if (latest === id) {
2929
2930
  hasLatest = false;
2930
2931
  isStopped && observer.onCompleted();
2931
2932
  }
2932
2933
  }));
2933
- },
2934
- observer.onError.bind(observer),
2934
+ },
2935
+ observer.onError.bind(observer),
2935
2936
  function () {
2936
2937
  isStopped = true;
2937
2938
  !hasLatest && observer.onCompleted();
@@ -2943,7 +2944,7 @@
2943
2944
  /**
2944
2945
  * Returns the values from the source observable sequence until the other observable sequence produces a value.
2945
2946
  * @param {Observable | Promise} other Observable sequence or Promise that terminates propagation of elements of the source sequence.
2946
- * @returns {Observable} An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.
2947
+ * @returns {Observable} An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.
2947
2948
  */
2948
2949
  observableProto.takeUntil = function (other) {
2949
2950
  var source = this;
@@ -2975,7 +2976,7 @@
2975
2976
  }
2976
2977
  }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
2977
2978
  });
2978
- }
2979
+ }
2979
2980
 
2980
2981
  /**
2981
2982
  * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index.
@@ -2983,9 +2984,9 @@
2983
2984
  *
2984
2985
  * @example
2985
2986
  * 1 - res = obs1.zip(obs2, fn);
2986
- * 1 - res = x1.zip([1,2,3], fn);
2987
- * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
2988
- */
2987
+ * 1 - res = x1.zip([1,2,3], fn);
2988
+ * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
2989
+ */
2989
2990
  observableProto.zip = function () {
2990
2991
  if (Array.isArray(arguments[0])) {
2991
2992
  return zipArray.apply(this, arguments);
@@ -2996,7 +2997,7 @@
2996
2997
  var n = sources.length,
2997
2998
  queues = arrayInitialize(n, function () { return []; }),
2998
2999
  isDone = arrayInitialize(n, function () { return false; });
2999
-
3000
+
3000
3001
  function next(i) {
3001
3002
  var res, queuedValues;
3002
3003
  if (queues.every(function (x) { return x.length > 0; })) {
@@ -3038,74 +3039,72 @@
3038
3039
  return new CompositeDisposable(subscriptions);
3039
3040
  });
3040
3041
  };
3041
- /**
3042
- * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
3043
- * @param arguments Observable sources.
3044
- * @param {Function} resultSelector Function to invoke for each series of elements at corresponding indexes in the sources.
3045
- * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
3046
- */
3047
- Observable.zip = function () {
3048
- var args = slice.call(arguments, 0),
3049
- first = args.shift();
3050
- return first.zip.apply(first, args);
3051
- };
3052
3042
 
3053
- /**
3054
- * Merges the specified observable sequences into one observable sequence by emitting a list with the elements of the observable sequences at corresponding indexes.
3055
- * @param arguments Observable sources.
3056
- * @returns {Observable} An observable sequence containing lists of elements at corresponding indexes.
3057
- */
3058
- Observable.zipArray = function () {
3059
- var sources = argsOrArray(arguments, 0);
3060
- return new AnonymousObservable(function (observer) {
3061
- var n = sources.length,
3062
- queues = arrayInitialize(n, function () { return []; }),
3063
- isDone = arrayInitialize(n, function () { return false; });
3064
-
3065
- function next(i) {
3066
- if (queues.every(function (x) { return x.length > 0; })) {
3067
- var res = queues.map(function (x) { return x.shift(); });
3068
- observer.onNext(res);
3069
- } else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) {
3070
- observer.onCompleted();
3071
- return;
3072
- }
3073
- };
3043
+ /**
3044
+ * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
3045
+ * @param arguments Observable sources.
3046
+ * @param {Function} resultSelector Function to invoke for each series of elements at corresponding indexes in the sources.
3047
+ * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
3048
+ */
3049
+ Observable.zip = function () {
3050
+ var args = slice.call(arguments, 0), first = args.shift();
3051
+ return first.zip.apply(first, args);
3052
+ };
3074
3053
 
3075
- function done(i) {
3076
- isDone[i] = true;
3077
- if (isDone.every(identity)) {
3078
- observer.onCompleted();
3079
- return;
3080
- }
3081
- }
3054
+ /**
3055
+ * Merges the specified observable sequences into one observable sequence by emitting a list with the elements of the observable sequences at corresponding indexes.
3056
+ * @param arguments Observable sources.
3057
+ * @returns {Observable} An observable sequence containing lists of elements at corresponding indexes.
3058
+ */
3059
+ Observable.zipArray = function () {
3060
+ var sources = argsOrArray(arguments, 0);
3061
+ return new AnonymousObservable(function (observer) {
3062
+ var n = sources.length,
3063
+ queues = arrayInitialize(n, function () { return []; }),
3064
+ isDone = arrayInitialize(n, function () { return false; });
3082
3065
 
3083
- var subscriptions = new Array(n);
3084
- for (var idx = 0; idx < n; idx++) {
3085
- (function (i) {
3086
- subscriptions[i] = new SingleAssignmentDisposable();
3087
- subscriptions[i].setDisposable(sources[i].subscribe(function (x) {
3088
- queues[i].push(x);
3089
- next(i);
3090
- }, observer.onError.bind(observer), function () {
3091
- done(i);
3092
- }));
3093
- })(idx);
3094
- }
3066
+ function next(i) {
3067
+ if (queues.every(function (x) { return x.length > 0; })) {
3068
+ var res = queues.map(function (x) { return x.shift(); });
3069
+ observer.onNext(res);
3070
+ } else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) {
3071
+ observer.onCompleted();
3072
+ return;
3073
+ }
3074
+ };
3095
3075
 
3096
- var compositeDisposable = new CompositeDisposable(subscriptions);
3097
- compositeDisposable.add(disposableCreate(function () {
3098
- for (var qIdx = 0, qLen = queues.length; qIdx < qLen; qIdx++) {
3099
- queues[qIdx] = [];
3100
- }
3101
- }));
3102
- return compositeDisposable;
3103
- });
3104
- };
3076
+ function done(i) {
3077
+ isDone[i] = true;
3078
+ if (isDone.every(identity)) {
3079
+ observer.onCompleted();
3080
+ return;
3081
+ }
3082
+ }
3083
+
3084
+ var subscriptions = new Array(n);
3085
+ for (var idx = 0; idx < n; idx++) {
3086
+ (function (i) {
3087
+ subscriptions[i] = new SingleAssignmentDisposable();
3088
+ subscriptions[i].setDisposable(sources[i].subscribe(function (x) {
3089
+ queues[i].push(x);
3090
+ next(i);
3091
+ }, observer.onError.bind(observer), function () {
3092
+ done(i);
3093
+ }));
3094
+ })(idx);
3095
+ }
3096
+
3097
+ var compositeDisposable = new CompositeDisposable(subscriptions);
3098
+ compositeDisposable.add(disposableCreate(function () {
3099
+ for (var qIdx = 0, qLen = queues.length; qIdx < qLen; qIdx++) { queues[qIdx] = []; }
3100
+ }));
3101
+ return compositeDisposable;
3102
+ });
3103
+ };
3105
3104
 
3106
3105
  /**
3107
3106
  * Hides the identity of an observable sequence.
3108
- * @returns {Observable} An observable sequence that hides the identity of the source sequence.
3107
+ * @returns {Observable} An observable sequence that hides the identity of the source sequence.
3109
3108
  */
3110
3109
  observableProto.asObservable = function () {
3111
3110
  return new AnonymousObservable(this.subscribe.bind(this));
@@ -3113,13 +3112,13 @@
3113
3112
 
3114
3113
  /**
3115
3114
  * Projects each element of an observable sequence into zero or more buffers which are produced based on element count information.
3116
- *
3115
+ *
3117
3116
  * @example
3118
3117
  * var res = xs.bufferWithCount(10);
3119
3118
  * var res = xs.bufferWithCount(10, 1);
3120
3119
  * @param {Number} count Length of each buffer.
3121
3120
  * @param {Number} [skip] Number of elements to skip between creation of consecutive buffers. If not provided, defaults to the count.
3122
- * @returns {Observable} An observable sequence of buffers.
3121
+ * @returns {Observable} An observable sequence of buffers.
3123
3122
  */
3124
3123
  observableProto.bufferWithCount = function (count, skip) {
3125
3124
  if (typeof skip !== 'number') {
@@ -3135,7 +3134,7 @@
3135
3134
  /**
3136
3135
  * Dematerializes the explicit notification values of an observable sequence as implicit notifications.
3137
3136
  * @returns {Observable} An observable sequence exhibiting the behavior corresponding to the source sequence's notification values.
3138
- */
3137
+ */
3139
3138
  observableProto.dematerialize = function () {
3140
3139
  var source = this;
3141
3140
  return new AnonymousObservable(function (observer) {
@@ -3147,14 +3146,14 @@
3147
3146
 
3148
3147
  /**
3149
3148
  * Returns an observable sequence that contains only distinct contiguous elements according to the keySelector and the comparer.
3150
- *
3149
+ *
3151
3150
  * var obs = observable.distinctUntilChanged();
3152
3151
  * var obs = observable.distinctUntilChanged(function (x) { return x.id; });
3153
3152
  * var obs = observable.distinctUntilChanged(function (x) { return x.id; }, function (x, y) { return x === y; });
3154
3153
  *
3155
3154
  * @param {Function} [keySelector] A function to compute the comparison key for each element. If not provided, it projects the value.
3156
3155
  * @param {Function} [comparer] Equality comparer for computed key values. If not provided, defaults to an equality comparer function.
3157
- * @returns {Observable} An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence.
3156
+ * @returns {Observable} An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence.
3158
3157
  */
3159
3158
  observableProto.distinctUntilChanged = function (keySelector, comparer) {
3160
3159
  var source = this;
@@ -3190,16 +3189,10 @@
3190
3189
  /**
3191
3190
  * Invokes an action for each element in the observable sequence and invokes an action upon graceful or exceptional termination of the observable sequence.
3192
3191
  * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
3193
- *
3194
- * @example
3195
- * var res = observable.do(observer);
3196
- * var res = observable.do(onNext);
3197
- * var res = observable.do(onNext, onError);
3198
- * var res = observable.do(onNext, onError, onCompleted);
3199
3192
  * @param {Function | Observer} observerOrOnNext Action to invoke for each element in the observable sequence or an observer.
3200
3193
  * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.
3201
3194
  * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.
3202
- * @returns {Observable} The source sequence with the side-effecting behavior applied.
3195
+ * @returns {Observable} The source sequence with the side-effecting behavior applied.
3203
3196
  */
3204
3197
  observableProto['do'] = observableProto.doAction = observableProto.tap = function (observerOrOnNext, onError, onCompleted) {
3205
3198
  var source = this, onNextFunc;
@@ -3219,39 +3212,68 @@
3219
3212
  }
3220
3213
  observer.onNext(x);
3221
3214
  }, function (err) {
3222
- if (!onError) {
3223
- observer.onError(err);
3224
- } else {
3215
+ if (onError) {
3225
3216
  try {
3226
3217
  onError(err);
3227
3218
  } catch (e) {
3228
3219
  observer.onError(e);
3229
3220
  }
3230
- observer.onError(err);
3231
3221
  }
3222
+ observer.onError(err);
3232
3223
  }, function () {
3233
- if (!onCompleted) {
3234
- observer.onCompleted();
3235
- } else {
3224
+ if (onCompleted) {
3236
3225
  try {
3237
3226
  onCompleted();
3238
3227
  } catch (e) {
3239
3228
  observer.onError(e);
3240
3229
  }
3241
- observer.onCompleted();
3242
3230
  }
3231
+ observer.onCompleted();
3243
3232
  });
3244
3233
  });
3245
3234
  };
3246
3235
 
3236
+ /**
3237
+ * Invokes an action for each element in the observable sequence.
3238
+ * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
3239
+ * @param {Function} onNext Action to invoke for each element in the observable sequence.
3240
+ * @param {Any} [thisArg] Object to use as this when executing callback.
3241
+ * @returns {Observable} The source sequence with the side-effecting behavior applied.
3242
+ */
3243
+ observableProto.doOnNext = observableProto.tapOnNext = function (onNext, thisArg) {
3244
+ return this.tap(arguments.length === 2 ? function (x) { onNext.call(thisArg, x); } : onNext);
3245
+ };
3246
+
3247
+ /**
3248
+ * Invokes an action upon exceptional termination of the observable sequence.
3249
+ * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
3250
+ * @param {Function} onError Action to invoke upon exceptional termination of the observable sequence.
3251
+ * @param {Any} [thisArg] Object to use as this when executing callback.
3252
+ * @returns {Observable} The source sequence with the side-effecting behavior applied.
3253
+ */
3254
+ observableProto.doOnError = observableProto.tapOnError = function (onError, thisArg) {
3255
+ return this.tap(noop, arguments.length === 2 ? function (e) { onError.call(thisArg, e); } : onError);
3256
+ };
3257
+
3258
+ /**
3259
+ * Invokes an action upon graceful termination of the observable sequence.
3260
+ * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
3261
+ * @param {Function} onCompleted Action to invoke upon graceful termination of the observable sequence.
3262
+ * @param {Any} [thisArg] Object to use as this when executing callback.
3263
+ * @returns {Observable} The source sequence with the side-effecting behavior applied.
3264
+ */
3265
+ observableProto.doOnCompleted = observableProto.tapOnCompleted = function (onCompleted, thisArg) {
3266
+ return this.tap(noop, null, arguments.length === 2 ? function () { onCompleted.call(thisArg); } : onCompleted);
3267
+ };
3268
+
3247
3269
  /**
3248
3270
  * Invokes a specified action after the source observable sequence terminates gracefully or exceptionally.
3249
- *
3271
+ *
3250
3272
  * @example
3251
3273
  * var res = observable.finallyAction(function () { console.log('sequence ended'; });
3252
3274
  * @param {Function} finallyAction Action to invoke after the source observable sequence terminates.
3253
- * @returns {Observable} Source sequence with the action-invoking termination behavior applied.
3254
- */
3275
+ * @returns {Observable} Source sequence with the action-invoking termination behavior applied.
3276
+ */
3255
3277
  observableProto['finally'] = observableProto.finallyAction = function (action) {
3256
3278
  var source = this;
3257
3279
  return new AnonymousObservable(function (observer) {
@@ -3265,8 +3287,8 @@
3265
3287
  return disposableCreate(function () {
3266
3288
  try {
3267
3289
  subscription.dispose();
3268
- } catch (e) {
3269
- throw e;
3290
+ } catch (e) {
3291
+ throw e;
3270
3292
  } finally {
3271
3293
  action();
3272
3294
  }
@@ -3276,7 +3298,7 @@
3276
3298
 
3277
3299
  /**
3278
3300
  * Ignores all elements in an observable sequence leaving only the termination messages.
3279
- * @returns {Observable} An empty observable sequence that signals termination, successful or exceptional, of the source sequence.
3301
+ * @returns {Observable} An empty observable sequence that signals termination, successful or exceptional, of the source sequence.
3280
3302
  */
3281
3303
  observableProto.ignoreElements = function () {
3282
3304
  var source = this;
@@ -3288,7 +3310,7 @@
3288
3310
  /**
3289
3311
  * Materializes the implicit notifications of an observable sequence as explicit notification values.
3290
3312
  * @returns {Observable} An observable sequence containing the materialized notification values from the source sequence.
3291
- */
3313
+ */
3292
3314
  observableProto.materialize = function () {
3293
3315
  var source = this;
3294
3316
  return new AnonymousObservable(function (observer) {
@@ -3306,12 +3328,12 @@
3306
3328
 
3307
3329
  /**
3308
3330
  * Repeats the observable sequence a specified number of times. If the repeat count is not specified, the sequence repeats indefinitely.
3309
- *
3331
+ *
3310
3332
  * @example
3311
3333
  * var res = repeated = source.repeat();
3312
3334
  * var res = repeated = source.repeat(42);
3313
3335
  * @param {Number} [repeatCount] Number of times to repeat the sequence. If not provided, repeats the sequence indefinitely.
3314
- * @returns {Observable} The observable sequence producing the elements of the given sequence repeatedly.
3336
+ * @returns {Observable} The observable sequence producing the elements of the given sequence repeatedly.
3315
3337
  */
3316
3338
  observableProto.repeat = function (repeatCount) {
3317
3339
  return enumerableRepeat(this, repeatCount).concat();
@@ -3320,12 +3342,12 @@
3320
3342
  /**
3321
3343
  * Repeats the source observable sequence the specified number of times or until it successfully terminates. If the retry count is not specified, it retries indefinitely.
3322
3344
  * Note if you encounter an error and want it to retry once, then you must use .retry(2);
3323
- *
3345
+ *
3324
3346
  * @example
3325
3347
  * var res = retried = retry.repeat();
3326
3348
  * var res = retried = retry.repeat(2);
3327
3349
  * @param {Number} [retryCount] Number of times to retry the sequence. If not provided, retry the sequence indefinitely.
3328
- * @returns {Observable} An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.
3350
+ * @returns {Observable} An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.
3329
3351
  */
3330
3352
  observableProto.retry = function (retryCount) {
3331
3353
  return enumerableRepeat(this, retryCount).catchException();
@@ -3346,7 +3368,7 @@
3346
3368
  if (arguments.length === 2) {
3347
3369
  hasSeed = true;
3348
3370
  seed = arguments[0];
3349
- accumulator = arguments[1];
3371
+ accumulator = arguments[1];
3350
3372
  } else {
3351
3373
  accumulator = arguments[0];
3352
3374
  }
@@ -3361,7 +3383,7 @@
3361
3383
  } else {
3362
3384
  accumulation = hasSeed ? accumulator(seed, x) : x;
3363
3385
  hasAccumulation = true;
3364
- }
3386
+ }
3365
3387
  } catch (e) {
3366
3388
  observer.onError(e);
3367
3389
  return;
@@ -3382,9 +3404,9 @@
3382
3404
  * Bypasses a specified number of elements at the end of an observable sequence.
3383
3405
  * @description
3384
3406
  * This operator accumulates a queue with a length enough to store the first `count` elements. As more elements are
3385
- * received, elements are taken from the front of the queue and produced on the result sequence. This causes elements to be delayed.
3407
+ * received, elements are taken from the front of the queue and produced on the result sequence. This causes elements to be delayed.
3386
3408
  * @param count Number of elements to bypass at the end of the source sequence.
3387
- * @returns {Observable} An observable sequence containing the source sequence elements except for the bypassed ones at the end.
3409
+ * @returns {Observable} An observable sequence containing the source sequence elements except for the bypassed ones at the end.
3388
3410
  */
3389
3411
  observableProto.skipLast = function (count) {
3390
3412
  var source = this;
@@ -3403,7 +3425,7 @@
3403
3425
  * var res = source.startWith(1, 2, 3);
3404
3426
  * var res = source.startWith(Rx.Scheduler.timeout, 1, 2, 3);
3405
3427
  * @param {Arguments} args The specified values to prepend to the observable sequence
3406
- * @returns {Observable} The source sequence prepended with the specified values.
3428
+ * @returns {Observable} The source sequence prepended with the specified values.
3407
3429
  */
3408
3430
  observableProto.startWith = function () {
3409
3431
  var values, scheduler, start = 0;
@@ -3414,7 +3436,7 @@
3414
3436
  scheduler = immediateScheduler;
3415
3437
  }
3416
3438
  values = slice.call(arguments, start);
3417
- return enumerableFor([observableFromArray(values, scheduler), this]).concat();
3439
+ return enumerableOf([observableFromArray(values, scheduler), this]).concat();
3418
3440
  };
3419
3441
 
3420
3442
  /**
@@ -3424,7 +3446,7 @@
3424
3446
  * the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.
3425
3447
  * @param {Number} count Number of elements to take from the end of the source sequence.
3426
3448
  * @returns {Observable} An observable sequence containing the specified number of elements from the end of the source sequence.
3427
- */
3449
+ */
3428
3450
  observableProto.takeLast = function (count) {
3429
3451
  var source = this;
3430
3452
  return new AnonymousObservable(function (observer) {
@@ -3441,10 +3463,10 @@
3441
3463
 
3442
3464
  /**
3443
3465
  * Returns an array with the specified number of contiguous elements from the end of an observable sequence.
3444
- *
3466
+ *
3445
3467
  * @description
3446
3468
  * This operator accumulates a buffer with a length enough to store count elements. Upon completion of the
3447
- * source sequence, this buffer is produced on the result sequence.
3469
+ * source sequence, this buffer is produced on the result sequence.
3448
3470
  * @param {Number} count Number of elements to take from the end of the source sequence.
3449
3471
  * @returns {Observable} An observable sequence containing a single array with the specified number of elements from the end of the source sequence.
3450
3472
  */
@@ -3462,65 +3484,58 @@
3462
3484
  });
3463
3485
  };
3464
3486
 
3465
- /**
3466
- * Projects each element of an observable sequence into zero or more windows which are produced based on element count information.
3467
- *
3468
- * var res = xs.windowWithCount(10);
3469
- * var res = xs.windowWithCount(10, 1);
3470
- * @param {Number} count Length of each window.
3471
- * @param {Number} [skip] Number of elements to skip between creation of consecutive windows. If not specified, defaults to the count.
3472
- * @returns {Observable} An observable sequence of windows.
3473
- */
3474
- observableProto.windowWithCount = function (count, skip) {
3475
- var source = this;
3476
- if (count <= 0) {
3477
- throw new Error(argumentOutOfRange);
3478
- }
3479
- if (arguments.length === 1) {
3480
- skip = count;
3481
- }
3482
- if (skip <= 0) {
3483
- throw new Error(argumentOutOfRange);
3487
+ /**
3488
+ * Projects each element of an observable sequence into zero or more windows which are produced based on element count information.
3489
+ *
3490
+ * var res = xs.windowWithCount(10);
3491
+ * var res = xs.windowWithCount(10, 1);
3492
+ * @param {Number} count Length of each window.
3493
+ * @param {Number} [skip] Number of elements to skip between creation of consecutive windows. If not specified, defaults to the count.
3494
+ * @returns {Observable} An observable sequence of windows.
3495
+ */
3496
+ observableProto.windowWithCount = function (count, skip) {
3497
+ var source = this;
3498
+ +count || (count = 0);
3499
+ Math.abs(count) === Infinity && (count = 0);
3500
+ if (count <= 0) { throw new Error(argumentOutOfRange); }
3501
+ skip == null && (skip = count);
3502
+ +skip || (skip = 0);
3503
+ Math.abs(skip) === Infinity && (skip = 0);
3504
+
3505
+ if (skip <= 0) { throw new Error(argumentOutOfRange); }
3506
+ return new AnonymousObservable(function (observer) {
3507
+ var m = new SingleAssignmentDisposable(),
3508
+ refCountDisposable = new RefCountDisposable(m),
3509
+ n = 0,
3510
+ q = [];
3511
+
3512
+ function createWindow () {
3513
+ var s = new Subject();
3514
+ q.push(s);
3515
+ observer.onNext(addRef(s, refCountDisposable));
3516
+ }
3517
+
3518
+ createWindow();
3519
+
3520
+ m.setDisposable(source.subscribe(
3521
+ function (x) {
3522
+ for (var i = 0, len = q.length; i < len; i++) { q[i].onNext(x); }
3523
+ var c = n - count + 1;
3524
+ c >=0 && c % skip === 0 && q.shift().onCompleted();
3525
+ ++n % skip === 0 && createWindow();
3526
+ },
3527
+ function (e) {
3528
+ while (q.length > 0) { q.shift().onError(e); }
3529
+ observer.onError(e);
3530
+ },
3531
+ function () {
3532
+ while (q.length > 0) { q.shift().onCompleted(); }
3533
+ observer.onCompleted();
3484
3534
  }
3485
- return new AnonymousObservable(function (observer) {
3486
- var m = new SingleAssignmentDisposable(),
3487
- refCountDisposable = new RefCountDisposable(m),
3488
- n = 0,
3489
- q = [],
3490
- createWindow = function () {
3491
- var s = new Subject();
3492
- q.push(s);
3493
- observer.onNext(addRef(s, refCountDisposable));
3494
- };
3495
- createWindow();
3496
- m.setDisposable(source.subscribe(function (x) {
3497
- var s;
3498
- for (var i = 0, len = q.length; i < len; i++) {
3499
- q[i].onNext(x);
3500
- }
3501
- var c = n - count + 1;
3502
- if (c >= 0 && c % skip === 0) {
3503
- s = q.shift();
3504
- s.onCompleted();
3505
- }
3506
- n++;
3507
- if (n % skip === 0) {
3508
- createWindow();
3509
- }
3510
- }, function (exception) {
3511
- while (q.length > 0) {
3512
- q.shift().onError(exception);
3513
- }
3514
- observer.onError(exception);
3515
- }, function () {
3516
- while (q.length > 0) {
3517
- q.shift().onCompleted();
3518
- }
3519
- observer.onCompleted();
3520
- }));
3521
- return refCountDisposable;
3522
- });
3523
- };
3535
+ ));
3536
+ return refCountDisposable;
3537
+ });
3538
+ };
3524
3539
 
3525
3540
  function concatMap(source, selector, thisArg) {
3526
3541
  return source.map(function (x, i) {
@@ -3532,21 +3547,21 @@
3532
3547
  /**
3533
3548
  * One of the Following:
3534
3549
  * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
3535
- *
3550
+ *
3536
3551
  * @example
3537
3552
  * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); });
3538
3553
  * Or:
3539
3554
  * 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.
3540
- *
3555
+ *
3541
3556
  * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
3542
3557
  * Or:
3543
3558
  * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
3544
- *
3559
+ *
3545
3560
  * var res = source.concatMap(Rx.Observable.fromArray([1,2,3]));
3546
- * @param selector A transform function to apply to each element or an observable sequence to project each element from the
3561
+ * @param selector A transform function to apply to each element or an observable sequence to project each element from the
3547
3562
  * source sequence onto which could be either an observable or Promise.
3548
3563
  * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
3549
- * @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.
3564
+ * @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.
3550
3565
  */
3551
3566
  observableProto.selectConcat = observableProto.concatMap = function (selector, resultSelector, thisArg) {
3552
3567
  if (resultSelector) {
@@ -3569,9 +3584,9 @@
3569
3584
  * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element.
3570
3585
  * @param {Function} onError A transform function to apply when an error occurs in the source sequence.
3571
3586
  * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached.
3572
- * @param {Any} [thisArg] An optional "this" to use to invoke each transform.
3587
+ * @param {Any} [thisArg] An optional "this" to use to invoke each transform.
3573
3588
  * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence.
3574
- */
3589
+ */
3575
3590
  observableProto.concatMapObserver = observableProto.selectConcatObserver = function(onNext, onError, onCompleted, thisArg) {
3576
3591
  var source = this;
3577
3592
  return new AnonymousObservable(function (observer) {
@@ -3600,7 +3615,7 @@
3600
3615
  isPromise(result) && (result = observableFromPromise(result));
3601
3616
  observer.onNext(result);
3602
3617
  observer.onCompleted();
3603
- },
3618
+ },
3604
3619
  function () {
3605
3620
  var result;
3606
3621
  try {
@@ -3608,22 +3623,23 @@
3608
3623
  } catch (e) {
3609
3624
  observer.onError(e);
3610
3625
  return;
3611
- }
3612
- isPromise(result) && (result = observableFromPromise(result));
3626
+ }
3627
+ isPromise(result) && (result = observableFromPromise(result));
3613
3628
  observer.onNext(result);
3614
3629
  observer.onCompleted();
3615
3630
  });
3616
3631
  }).concatAll();
3617
3632
  };
3633
+
3618
3634
  /**
3619
3635
  * Returns the elements of the specified sequence or the specified value in a singleton sequence if the sequence is empty.
3620
- *
3636
+ *
3621
3637
  * var res = obs = xs.defaultIfEmpty();
3622
3638
  * 2 - obs = xs.defaultIfEmpty(false);
3623
- *
3639
+ *
3624
3640
  * @memberOf Observable#
3625
3641
  * @param defaultValue The value to return if the sequence is empty. If not provided, this defaults to null.
3626
- * @returns {Observable} An observable sequence that contains the specified default value if the source is empty; otherwise, the elements of the source itself.
3642
+ * @returns {Observable} An observable sequence that contains the specified default value if the source is empty; otherwise, the elements of the source itself.
3627
3643
  */
3628
3644
  observableProto.defaultIfEmpty = function (defaultValue) {
3629
3645
  var source = this;
@@ -3664,12 +3680,12 @@
3664
3680
 
3665
3681
  /**
3666
3682
  * Returns an observable sequence that contains only distinct elements according to the keySelector and the comparer.
3667
- * Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.
3668
- *
3683
+ * Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.
3684
+ *
3669
3685
  * @example
3670
3686
  * var res = obs = xs.distinct();
3671
3687
  * 2 - obs = xs.distinct(function (x) { return x.id; });
3672
- * 2 - obs = xs.distinct(function (x) { return x.id; }, function (a,b) { return a === b; });
3688
+ * 2 - obs = xs.distinct(function (x) { return x.id; }, function (a,b) { return a === b; });
3673
3689
  * @param {Function} [keySelector] A function to compute the comparison key for each element.
3674
3690
  * @param {Function} [comparer] Used to compare items in the collection.
3675
3691
  * @returns {Observable} An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence.
@@ -3688,37 +3704,37 @@
3688
3704
  } catch (e) {
3689
3705
  observer.onError(e);
3690
3706
  return;
3691
- }
3707
+ }
3692
3708
  }
3693
3709
  hashSet.push(key) && observer.onNext(x);
3694
- },
3695
- observer.onError.bind(observer),
3710
+ },
3711
+ observer.onError.bind(observer),
3696
3712
  observer.onCompleted.bind(observer));
3697
3713
  });
3698
3714
  };
3699
3715
 
3700
- /**
3701
- * Projects each element of an observable sequence into a new form by incorporating the element's index.
3702
- * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
3703
- * @param {Any} [thisArg] Object to use as this when executing callback.
3704
- * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source.
3705
- */
3706
- observableProto.select = observableProto.map = function (selector, thisArg) {
3707
- var parent = this;
3708
- return new AnonymousObservable(function (observer) {
3709
- var count = 0;
3710
- return parent.subscribe(function (value) {
3711
- var result;
3712
- try {
3713
- result = selector.call(thisArg, value, count++, parent);
3714
- } catch (exception) {
3715
- observer.onError(exception);
3716
- return;
3717
- }
3718
- observer.onNext(result);
3719
- }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
3720
- });
3721
- };
3716
+ /**
3717
+ * Projects each element of an observable sequence into a new form by incorporating the element's index.
3718
+ * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
3719
+ * @param {Any} [thisArg] Object to use as this when executing callback.
3720
+ * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source.
3721
+ */
3722
+ observableProto.select = observableProto.map = function (selector, thisArg) {
3723
+ var parent = this;
3724
+ return new AnonymousObservable(function (observer) {
3725
+ var count = 0;
3726
+ return parent.subscribe(function (value) {
3727
+ var result;
3728
+ try {
3729
+ result = selector.call(thisArg, value, count++, parent);
3730
+ } catch (e) {
3731
+ observer.onError(e);
3732
+ return;
3733
+ }
3734
+ observer.onNext(result);
3735
+ }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
3736
+ });
3737
+ };
3722
3738
 
3723
3739
  /**
3724
3740
  * Retrieves the value of a specified property from all elements in the Observable sequence.
@@ -3765,7 +3781,7 @@
3765
3781
  isPromise(result) && (result = observableFromPromise(result));
3766
3782
  observer.onNext(result);
3767
3783
  observer.onCompleted();
3768
- },
3784
+ },
3769
3785
  function () {
3770
3786
  var result;
3771
3787
  try {
@@ -3773,13 +3789,14 @@
3773
3789
  } catch (e) {
3774
3790
  observer.onError(e);
3775
3791
  return;
3776
- }
3777
- isPromise(result) && (result = observableFromPromise(result));
3792
+ }
3793
+ isPromise(result) && (result = observableFromPromise(result));
3778
3794
  observer.onNext(result);
3779
3795
  observer.onCompleted();
3780
3796
  });
3781
3797
  }).mergeAll();
3782
3798
  };
3799
+
3783
3800
  function flatMap(source, selector, thisArg) {
3784
3801
  return source.map(function (x, i) {
3785
3802
  var result = selector.call(thisArg, x, i);
@@ -3790,22 +3807,22 @@
3790
3807
  /**
3791
3808
  * One of the Following:
3792
3809
  * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
3793
- *
3810
+ *
3794
3811
  * @example
3795
3812
  * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); });
3796
3813
  * Or:
3797
3814
  * 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.
3798
- *
3815
+ *
3799
3816
  * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
3800
3817
  * Or:
3801
3818
  * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
3802
- *
3819
+ *
3803
3820
  * var res = source.selectMany(Rx.Observable.fromArray([1,2,3]));
3804
- * @param selector A transform function to apply to each element or an observable sequence to project each element from the
3821
+ * @param selector A transform function to apply to each element or an observable sequence to project each element from the
3805
3822
  * source sequence onto which could be either an observable or Promise.
3806
3823
  * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
3807
3824
  * @param {Any} [thisArg] Object to use as this when executing callback.
3808
- * @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.
3825
+ * @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.
3809
3826
  */
3810
3827
  observableProto.selectMany = observableProto.flatMap = function (selector, resultSelector, thisArg) {
3811
3828
  if (resultSelector) {
@@ -3824,11 +3841,11 @@
3824
3841
  };
3825
3842
 
3826
3843
  /**
3827
- * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then
3844
+ * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then
3828
3845
  * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
3829
3846
  * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
3830
3847
  * @param {Any} [thisArg] Object to use as this when executing callback.
3831
- * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences
3848
+ * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences
3832
3849
  * and that at any point in time produces the elements of the most recent inner observable sequence that has been received.
3833
3850
  */
3834
3851
  observableProto.selectSwitch = observableProto.flatMapLatest = observableProto.switchMap = function (selector, thisArg) {
@@ -3838,7 +3855,7 @@
3838
3855
  /**
3839
3856
  * Bypasses a specified number of elements in an observable sequence and then returns the remaining elements.
3840
3857
  * @param {Number} count The number of elements to skip before returning the remaining elements.
3841
- * @returns {Observable} An observable sequence that contains the elements that occur after the specified index in the input sequence.
3858
+ * @returns {Observable} An observable sequence that contains the elements that occur after the specified index in the input sequence.
3842
3859
  */
3843
3860
  observableProto.skip = function (count) {
3844
3861
  if (count < 0) { throw new Error(argumentOutOfRange); }
@@ -3858,12 +3875,12 @@
3858
3875
  /**
3859
3876
  * Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
3860
3877
  * The element's index is used in the logic of the predicate function.
3861
- *
3878
+ *
3862
3879
  * var res = source.skipWhile(function (value) { return value < 10; });
3863
3880
  * var res = source.skipWhile(function (value, index) { return value < 10 || index < 10; });
3864
3881
  * @param {Function} predicate A function to test each element for a condition; the second parameter of the function represents the index of the source element.
3865
- * @param {Any} [thisArg] Object to use as this when executing callback.
3866
- * @returns {Observable} An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate.
3882
+ * @param {Any} [thisArg] Object to use as this when executing callback.
3883
+ * @returns {Observable} An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate.
3867
3884
  */
3868
3885
  observableProto.skipWhile = function (predicate, thisArg) {
3869
3886
  var source = this;
@@ -3885,12 +3902,12 @@
3885
3902
 
3886
3903
  /**
3887
3904
  * Returns a specified number of contiguous elements from the start of an observable sequence, using the specified scheduler for the edge case of take(0).
3888
- *
3905
+ *
3889
3906
  * var res = source.take(5);
3890
3907
  * var res = source.take(0, Rx.Scheduler.timeout);
3891
3908
  * @param {Number} count The number of elements to return.
3892
3909
  * @param {Scheduler} [scheduler] Scheduler used to produce an OnCompleted message in case <paramref name="count count</paramref> is set to 0.
3893
- * @returns {Observable} An observable sequence that contains the specified number of elements from the start of the input sequence.
3910
+ * @returns {Observable} An observable sequence that contains the specified number of elements from the start of the input sequence.
3894
3911
  */
3895
3912
  observableProto.take = function (count, scheduler) {
3896
3913
  if (count < 0) { throw new RangeError(argumentOutOfRange); }
@@ -3911,8 +3928,8 @@
3911
3928
  * Returns elements from an observable sequence as long as a specified condition is true.
3912
3929
  * The element's index is used in the logic of the predicate function.
3913
3930
  * @param {Function} predicate A function to test each element for a condition; the second parameter of the function represents the index of the source element.
3914
- * @param {Any} [thisArg] Object to use as this when executing callback.
3915
- * @returns {Observable} An observable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes.
3931
+ * @param {Any} [thisArg] Object to use as this when executing callback.
3932
+ * @returns {Observable} An observable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes.
3916
3933
  */
3917
3934
  observableProto.takeWhile = function (predicate, thisArg) {
3918
3935
  var observable = this;
@@ -3936,34 +3953,32 @@
3936
3953
  });
3937
3954
  };
3938
3955
 
3939
- /**
3940
- * Filters the elements of an observable sequence based on a predicate by incorporating the element's index.
3941
- *
3942
- * @example
3943
- * var res = source.where(function (value) { return value < 10; });
3944
- * var res = source.where(function (value, index) { return value < 10 || index < 10; });
3945
- * @param {Function} predicate A function to test each source element for a condition; the second parameter of the function represents the index of the source element.
3946
- * @param {Any} [thisArg] Object to use as this when executing callback.
3947
- * @returns {Observable} An observable sequence that contains elements from the input sequence that satisfy the condition.
3948
- */
3949
- observableProto.where = observableProto.filter = function (predicate, thisArg) {
3950
- var parent = this;
3951
- return new AnonymousObservable(function (observer) {
3952
- var count = 0;
3953
- return parent.subscribe(function (value) {
3954
- var shouldRun;
3955
- try {
3956
- shouldRun = predicate.call(thisArg, value, count++, parent);
3957
- } catch (exception) {
3958
- observer.onError(exception);
3959
- return;
3960
- }
3961
- if (shouldRun) {
3962
- observer.onNext(value);
3963
- }
3964
- }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
3965
- });
3966
- };
3956
+ /**
3957
+ * Filters the elements of an observable sequence based on a predicate by incorporating the element's index.
3958
+ *
3959
+ * @example
3960
+ * var res = source.where(function (value) { return value < 10; });
3961
+ * var res = source.where(function (value, index) { return value < 10 || index < 10; });
3962
+ * @param {Function} predicate A function to test each source element for a condition; the second parameter of the function represents the index of the source element.
3963
+ * @param {Any} [thisArg] Object to use as this when executing callback.
3964
+ * @returns {Observable} An observable sequence that contains elements from the input sequence that satisfy the condition.
3965
+ */
3966
+ observableProto.where = observableProto.filter = function (predicate, thisArg) {
3967
+ var parent = this;
3968
+ return new AnonymousObservable(function (observer) {
3969
+ var count = 0;
3970
+ return parent.subscribe(function (value) {
3971
+ var shouldRun;
3972
+ try {
3973
+ shouldRun = predicate.call(thisArg, value, count++, parent);
3974
+ } catch (e) {
3975
+ observer.onError(e);
3976
+ return;
3977
+ }
3978
+ shouldRun && observer.onNext(value);
3979
+ }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
3980
+ });
3981
+ };
3967
3982
 
3968
3983
  /*
3969
3984
  * Performs a exclusive waiting for the first to finish before subscribing to another observable.
@@ -3984,7 +3999,7 @@
3984
3999
  function (innerSource) {
3985
4000
  if (!hasCurrent) {
3986
4001
  hasCurrent = true;
3987
-
4002
+
3988
4003
  isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
3989
4004
 
3990
4005
  var innerSubscription = new SingleAssignmentDisposable();
@@ -4005,7 +4020,7 @@
4005
4020
  observer.onError.bind(observer),
4006
4021
  function () {
4007
4022
  isStopped = true;
4008
- if (!hasCurrent && g.length === 1) {
4023
+ if (!hasCurrent && g.length === 1) {
4009
4024
  observer.onCompleted();
4010
4025
  }
4011
4026
  }));
@@ -4013,6 +4028,7 @@
4013
4028
  return g;
4014
4029
  });
4015
4030
  };
4031
+
4016
4032
  /*
4017
4033
  * Performs a exclusive map waiting for the first to finish before subscribing to another observable.
4018
4034
  * Observables that come in between subscriptions will be dropped on the floor.
@@ -4035,12 +4051,12 @@
4035
4051
  function (innerSource) {
4036
4052
 
4037
4053
  if (!hasCurrent) {
4038
- hasCurrent = true;
4054
+ hasCurrent = true;
4039
4055
 
4040
4056
  innerSubscription = new SingleAssignmentDisposable();
4041
4057
  g.add(innerSubscription);
4042
4058
 
4043
- isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
4059
+ isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
4044
4060
 
4045
4061
  innerSubscription.setDisposable(innerSource.subscribe(
4046
4062
  function (x) {
@@ -4064,7 +4080,7 @@
4064
4080
  }
4065
4081
  }));
4066
4082
  }
4067
- },
4083
+ },
4068
4084
  observer.onError.bind(observer),
4069
4085
  function () {
4070
4086
  isStopped = true;
@@ -4075,6 +4091,7 @@
4075
4091
  return g;
4076
4092
  });
4077
4093
  };
4094
+
4078
4095
  var AnonymousObservable = Rx.AnonymousObservable = (function (__super__) {
4079
4096
  inherits(AnonymousObservable, __super__);
4080
4097
 
@@ -4099,7 +4116,7 @@
4099
4116
  } catch (e) {
4100
4117
  if (!autoDetachObserver.fail(e)) {
4101
4118
  throw e;
4102
- }
4119
+ }
4103
4120
  }
4104
4121
  };
4105
4122
 
@@ -4137,8 +4154,8 @@
4137
4154
  try {
4138
4155
  this.observer.onNext(value);
4139
4156
  noError = true;
4140
- } catch (e) {
4141
- throw e;
4157
+ } catch (e) {
4158
+ throw e;
4142
4159
  } finally {
4143
4160
  if (!noError) {
4144
4161
  this.dispose();
@@ -4149,8 +4166,8 @@
4149
4166
  AutoDetachObserverPrototype.error = function (exn) {
4150
4167
  try {
4151
4168
  this.observer.onError(exn);
4152
- } catch (e) {
4153
- throw e;
4169
+ } catch (e) {
4170
+ throw e;
4154
4171
  } finally {
4155
4172
  this.dispose();
4156
4173
  }
@@ -4159,8 +4176,8 @@
4159
4176
  AutoDetachObserverPrototype.completed = function () {
4160
4177
  try {
4161
4178
  this.observer.onCompleted();
4162
- } catch (e) {
4163
- throw e;
4179
+ } catch (e) {
4180
+ throw e;
4164
4181
  } finally {
4165
4182
  this.dispose();
4166
4183
  }
@@ -4181,23 +4198,23 @@
4181
4198
  return AutoDetachObserver;
4182
4199
  }(AbstractObserver));
4183
4200
 
4184
- /** @private */
4185
- var InnerSubscription = function (subject, observer) {
4186
- this.subject = subject;
4187
- this.observer = observer;
4188
- };
4189
-
4190
- /**
4191
- * @private
4192
- * @memberOf InnerSubscription
4193
- */
4194
- InnerSubscription.prototype.dispose = function () {
4195
- if (!this.subject.isDisposed && this.observer !== null) {
4196
- var idx = this.subject.observers.indexOf(this.observer);
4197
- this.subject.observers.splice(idx, 1);
4198
- this.observer = null;
4199
- }
4200
- };
4201
+ /** @private */
4202
+ var InnerSubscription = function (subject, observer) {
4203
+ this.subject = subject;
4204
+ this.observer = observer;
4205
+ };
4206
+
4207
+ /**
4208
+ * @private
4209
+ * @memberOf InnerSubscription
4210
+ */
4211
+ InnerSubscription.prototype.dispose = function () {
4212
+ if (!this.subject.isDisposed && this.observer !== null) {
4213
+ var idx = this.subject.observers.indexOf(this.observer);
4214
+ this.subject.observers.splice(idx, 1);
4215
+ this.observer = null;
4216
+ }
4217
+ };
4201
4218
 
4202
4219
  /**
4203
4220
  * Represents an object that is both an observable sequence as well as an observer.
@@ -4223,7 +4240,7 @@
4223
4240
  /**
4224
4241
  * Creates a subject.
4225
4242
  * @constructor
4226
- */
4243
+ */
4227
4244
  function Subject() {
4228
4245
  _super.call(this, subscribe);
4229
4246
  this.isDisposed = false,
@@ -4235,13 +4252,13 @@
4235
4252
  /**
4236
4253
  * Indicates whether the subject has observers subscribed to it.
4237
4254
  * @returns {Boolean} Indicates whether the subject has observers subscribed to it.
4238
- */
4255
+ */
4239
4256
  hasObservers: function () {
4240
4257
  return this.observers.length > 0;
4241
4258
  },
4242
4259
  /**
4243
4260
  * Notifies all subscribed observers about the end of the sequence.
4244
- */
4261
+ */
4245
4262
  onCompleted: function () {
4246
4263
  checkDisposed.call(this);
4247
4264
  if (!this.isStopped) {
@@ -4257,7 +4274,7 @@
4257
4274
  /**
4258
4275
  * Notifies all subscribed observers about the exception.
4259
4276
  * @param {Mixed} error The exception to send to all observers.
4260
- */
4277
+ */
4261
4278
  onError: function (exception) {
4262
4279
  checkDisposed.call(this);
4263
4280
  if (!this.isStopped) {
@@ -4274,7 +4291,7 @@
4274
4291
  /**
4275
4292
  * Notifies all subscribed observers about the arrival of the specified element in the sequence.
4276
4293
  * @param {Mixed} value The value to send to all observers.
4277
- */
4294
+ */
4278
4295
  onNext: function (value) {
4279
4296
  checkDisposed.call(this);
4280
4297
  if (!this.isStopped) {
@@ -4286,7 +4303,7 @@
4286
4303
  },
4287
4304
  /**
4288
4305
  * Unsubscribe all observers and release resources.
4289
- */
4306
+ */
4290
4307
  dispose: function () {
4291
4308
  this.isDisposed = true;
4292
4309
  this.observers = null;
@@ -4309,12 +4326,12 @@
4309
4326
  /**
4310
4327
  * Represents the result of an asynchronous operation.
4311
4328
  * The last value before the OnCompleted notification, or the error received through OnError, is sent to all subscribed observers.
4312
- */
4329
+ */
4313
4330
  var AsyncSubject = Rx.AsyncSubject = (function (__super__) {
4314
4331
 
4315
4332
  function subscribe(observer) {
4316
4333
  checkDisposed.call(this);
4317
-
4334
+
4318
4335
  if (!this.isStopped) {
4319
4336
  this.observers.push(observer);
4320
4337
  return new InnerSubscription(this, observer);
@@ -4341,7 +4358,7 @@
4341
4358
  /**
4342
4359
  * Creates a subject that can only receive one value and that value is cached for all future observations.
4343
4360
  * @constructor
4344
- */
4361
+ */
4345
4362
  function AsyncSubject() {
4346
4363
  __super__.call(this, subscribe);
4347
4364
 
@@ -4357,14 +4374,14 @@
4357
4374
  /**
4358
4375
  * Indicates whether the subject has observers subscribed to it.
4359
4376
  * @returns {Boolean} Indicates whether the subject has observers subscribed to it.
4360
- */
4377
+ */
4361
4378
  hasObservers: function () {
4362
4379
  checkDisposed.call(this);
4363
4380
  return this.observers.length > 0;
4364
4381
  },
4365
4382
  /**
4366
4383
  * Notifies all subscribed observers about the end of the sequence, also causing the last received value to be sent out (if any).
4367
- */
4384
+ */
4368
4385
  onCompleted: function () {
4369
4386
  var o, i, len;
4370
4387
  checkDisposed.call(this);
@@ -4392,7 +4409,7 @@
4392
4409
  /**
4393
4410
  * Notifies all subscribed observers about the error.
4394
4411
  * @param {Mixed} error The Error to send to all observers.
4395
- */
4412
+ */
4396
4413
  onError: function (error) {
4397
4414
  checkDisposed.call(this);
4398
4415
  if (!this.isStopped) {
@@ -4410,7 +4427,7 @@
4410
4427
  /**
4411
4428
  * Sends a value to the subject. The last value received before successful termination will be sent to all subscribed and future observers.
4412
4429
  * @param {Mixed} value The value to store in the subject.
4413
- */
4430
+ */
4414
4431
  onNext: function (value) {
4415
4432
  checkDisposed.call(this);
4416
4433
  if (this.isStopped) { return; }
@@ -4431,45 +4448,46 @@
4431
4448
  return AsyncSubject;
4432
4449
  }(Observable));
4433
4450
 
4434
- var AnonymousSubject = Rx.AnonymousSubject = (function (__super__) {
4435
- inherits(AnonymousSubject, __super__);
4436
-
4437
- function AnonymousSubject(observer, observable) {
4438
- this.observer = observer;
4439
- this.observable = observable;
4440
- __super__.call(this, this.observable.subscribe.bind(this.observable));
4441
- }
4442
-
4443
- addProperties(AnonymousSubject.prototype, Observer, {
4444
- onCompleted: function () {
4445
- this.observer.onCompleted();
4446
- },
4447
- onError: function (exception) {
4448
- this.observer.onError(exception);
4449
- },
4450
- onNext: function (value) {
4451
- this.observer.onNext(value);
4452
- }
4453
- });
4454
-
4455
- return AnonymousSubject;
4456
- }(Observable));
4457
-
4458
- if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
4459
- root.Rx = Rx;
4460
-
4461
- define(function() {
4462
- return Rx;
4463
- });
4464
- } else if (freeExports && freeModule) {
4465
- // in Node.js or RingoJS
4466
- if (moduleExports) {
4467
- (freeModule.exports = Rx).Rx = Rx;
4468
- } else {
4469
- freeExports.Rx = Rx;
4470
- }
4471
- } else {
4472
- // in a browser or Rhino
4473
- root.Rx = Rx;
4451
+ var AnonymousSubject = Rx.AnonymousSubject = (function (__super__) {
4452
+ inherits(AnonymousSubject, __super__);
4453
+
4454
+ function AnonymousSubject(observer, observable) {
4455
+ this.observer = observer;
4456
+ this.observable = observable;
4457
+ __super__.call(this, this.observable.subscribe.bind(this.observable));
4458
+ }
4459
+
4460
+ addProperties(AnonymousSubject.prototype, Observer, {
4461
+ onCompleted: function () {
4462
+ this.observer.onCompleted();
4463
+ },
4464
+ onError: function (exception) {
4465
+ this.observer.onError(exception);
4466
+ },
4467
+ onNext: function (value) {
4468
+ this.observer.onNext(value);
4469
+ }
4470
+ });
4471
+
4472
+ return AnonymousSubject;
4473
+ }(Observable));
4474
+
4475
+ if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
4476
+ root.Rx = Rx;
4477
+
4478
+ define(function() {
4479
+ return Rx;
4480
+ });
4481
+ } else if (freeExports && freeModule) {
4482
+ // in Node.js or RingoJS
4483
+ if (moduleExports) {
4484
+ (freeModule.exports = Rx).Rx = Rx;
4485
+ } else {
4486
+ freeExports.Rx = Rx;
4487
+ }
4488
+ } else {
4489
+ // in a browser or Rhino
4490
+ root.Rx = Rx;
4474
4491
  }
4475
- }.call(this));
4492
+
4493
+ }.call(this));