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.
- checksums.yaml +4 -4
- data/lib/rxjs/rails/version.rb +1 -1
- data/vendor/assets/javascripts/rx.aggregates.js +120 -70
- data/vendor/assets/javascripts/rx.aggregates.min.js +3 -1
- data/vendor/assets/javascripts/rx.all.compat.js +1810 -1849
- data/vendor/assets/javascripts/rx.all.compat.min.js +5 -3
- data/vendor/assets/javascripts/rx.all.js +1776 -1815
- data/vendor/assets/javascripts/rx.all.min.js +5 -3
- data/vendor/assets/javascripts/rx.async.compat.js +45 -45
- data/vendor/assets/javascripts/rx.async.compat.min.js +3 -1
- data/vendor/assets/javascripts/rx.async.js +39 -39
- data/vendor/assets/javascripts/rx.async.min.js +3 -1
- data/vendor/assets/javascripts/rx.backpressure.js +21 -19
- data/vendor/assets/javascripts/rx.backpressure.min.js +3 -1
- data/vendor/assets/javascripts/rx.binding.js +90 -90
- data/vendor/assets/javascripts/rx.binding.min.js +3 -1
- data/vendor/assets/javascripts/rx.coincidence.js +184 -179
- data/vendor/assets/javascripts/rx.coincidence.min.js +3 -1
- data/vendor/assets/javascripts/rx.compat.js +1019 -1001
- data/vendor/assets/javascripts/rx.compat.min.js +4 -2
- data/vendor/assets/javascripts/rx.experimental.js +65 -64
- data/vendor/assets/javascripts/rx.experimental.min.js +3 -1
- data/vendor/assets/javascripts/rx.joinpatterns.js +265 -363
- data/vendor/assets/javascripts/rx.joinpatterns.min.js +3 -1
- data/vendor/assets/javascripts/rx.js +969 -951
- data/vendor/assets/javascripts/rx.lite.compat.js +1014 -1182
- data/vendor/assets/javascripts/rx.lite.compat.min.js +4 -2
- data/vendor/assets/javascripts/rx.lite.extras.js +101 -109
- data/vendor/assets/javascripts/rx.lite.extras.min.js +3 -1
- data/vendor/assets/javascripts/rx.lite.js +1008 -1176
- data/vendor/assets/javascripts/rx.lite.min.js +4 -2
- data/vendor/assets/javascripts/rx.min.js +4 -2
- data/vendor/assets/javascripts/rx.testing.js +196 -196
- data/vendor/assets/javascripts/rx.testing.min.js +3 -1
- data/vendor/assets/javascripts/rx.time.js +162 -178
- data/vendor/assets/javascripts/rx.time.min.js +3 -1
- data/vendor/assets/javascripts/rx.virtualtime.js +30 -30
- data/vendor/assets/javascripts/rx.virtualtime.min.js +3 -1
- metadata +2 -6
- data/vendor/assets/javascripts/rx.core.compat.js +0 -2548
- data/vendor/assets/javascripts/rx.core.compat.min.js +0 -1
- data/vendor/assets/javascripts/rx.core.js +0 -2430
- 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
34
|
notDefined = Rx.helpers.notDefined = function (x) { return typeof x === 'undefined'; },
|
35
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 = (function () { return !!Date.now ? Date.now : function () { return +new Date; }; }()),
|
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
67
|
function checkDisposed() { if (this.isDisposed) { throw new Error(objectDisposed); } }
|
68
|
-
|
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,47 +359,45 @@
|
|
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);
|
365
|
-
}
|
366
|
-
var hasProp = {}.hasOwnProperty;
|
367
362
|
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
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;
|
374
370
|
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
for (var prop in source) {
|
381
|
-
obj[prop] = source[prop];
|
382
|
-
}
|
383
|
-
}
|
384
|
-
};
|
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
|
+
};
|
385
376
|
|
386
|
-
|
387
|
-
var
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
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
|
+
}
|
384
|
+
}
|
385
|
+
};
|
392
386
|
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
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
|
+
};
|
393
|
+
|
394
|
+
function arrayInitialize(count, factory) {
|
395
|
+
var a = new Array(count);
|
396
|
+
for (var i = 0; i < count; i++) {
|
397
|
+
a[i] = factory();
|
400
398
|
}
|
399
|
+
return a;
|
400
|
+
}
|
401
401
|
|
402
402
|
// Utilities
|
403
403
|
if (!Function.prototype.bind) {
|
@@ -550,91 +550,92 @@ if (!Array.prototype.forEach) {
|
|
550
550
|
};
|
551
551
|
}
|
552
552
|
|
553
|
-
// Collections
|
554
|
-
function IndexedItem(id, value) {
|
555
|
-
this.id = id;
|
556
|
-
this.value = value;
|
557
|
-
}
|
558
|
-
|
559
|
-
IndexedItem.prototype.compareTo = function (other) {
|
560
|
-
var c = this.value.compareTo(other.value);
|
561
|
-
c === 0 && (c = this.id - other.id);
|
562
|
-
return c;
|
563
|
-
};
|
564
|
-
|
565
|
-
// Priority Queue for Scheduling
|
566
|
-
var PriorityQueue = Rx.internals.PriorityQueue = function (capacity) {
|
567
|
-
this.items = new Array(capacity);
|
568
|
-
this.length = 0;
|
569
|
-
};
|
570
|
-
|
571
|
-
var priorityProto = PriorityQueue.prototype;
|
572
|
-
priorityProto.isHigherPriority = function (left, right) {
|
573
|
-
return this.items[left].compareTo(this.items[right]) < 0;
|
574
|
-
};
|
575
|
-
|
576
|
-
priorityProto.percolate = function (index) {
|
577
|
-
if (index >= this.length || index < 0) { return; }
|
578
|
-
var parent = index - 1 >> 1;
|
579
|
-
if (parent < 0 || parent === index) { return; }
|
580
|
-
if (this.isHigherPriority(index, parent)) {
|
581
|
-
var temp = this.items[index];
|
582
|
-
this.items[index] = this.items[parent];
|
583
|
-
this.items[parent] = temp;
|
584
|
-
this.percolate(parent);
|
585
|
-
}
|
586
|
-
};
|
587
|
-
|
588
|
-
priorityProto.heapify = function (index) {
|
589
|
-
+index || (index = 0);
|
590
|
-
if (index >= this.length || index < 0) { return; }
|
591
|
-
var left = 2 * index + 1,
|
592
|
-
right = 2 * index + 2,
|
593
|
-
first = index;
|
594
|
-
if (left < this.length && this.isHigherPriority(left, first)) {
|
595
|
-
first = left;
|
596
|
-
}
|
597
|
-
if (right < this.length && this.isHigherPriority(right, first)) {
|
598
|
-
first = right;
|
599
|
-
}
|
600
|
-
if (first !== index) {
|
601
|
-
var temp = this.items[index];
|
602
|
-
this.items[index] = this.items[first];
|
603
|
-
this.items[first] = temp;
|
604
|
-
this.heapify(first);
|
605
|
-
}
|
606
|
-
};
|
607
|
-
|
608
|
-
priorityProto.peek = function () { return this.items[0].value; };
|
609
|
-
|
610
|
-
priorityProto.removeAt = function (index) {
|
611
|
-
this.items[index] = this.items[--this.length];
|
612
|
-
delete this.items[this.length];
|
613
|
-
this.heapify();
|
614
|
-
};
|
615
|
-
|
616
|
-
priorityProto.dequeue = function () {
|
617
|
-
var result = this.peek();
|
618
|
-
this.removeAt(0);
|
619
|
-
return result;
|
620
|
-
};
|
621
|
-
|
622
|
-
priorityProto.enqueue = function (item) {
|
623
|
-
var index = this.length++;
|
624
|
-
this.items[index] = new IndexedItem(PriorityQueue.count++, item);
|
625
|
-
this.percolate(index);
|
626
|
-
};
|
627
|
-
|
628
|
-
priorityProto.remove = function (item) {
|
629
|
-
for (var i = 0; i < this.length; i++) {
|
630
|
-
if (this.items[i].value === item) {
|
631
|
-
this.removeAt(i);
|
632
|
-
return true;
|
633
|
-
}
|
634
|
-
}
|
635
|
-
return false;
|
636
|
-
};
|
553
|
+
// Collections
|
554
|
+
function IndexedItem(id, value) {
|
555
|
+
this.id = id;
|
556
|
+
this.value = value;
|
557
|
+
}
|
558
|
+
|
559
|
+
IndexedItem.prototype.compareTo = function (other) {
|
560
|
+
var c = this.value.compareTo(other.value);
|
561
|
+
c === 0 && (c = this.id - other.id);
|
562
|
+
return c;
|
563
|
+
};
|
564
|
+
|
565
|
+
// Priority Queue for Scheduling
|
566
|
+
var PriorityQueue = Rx.internals.PriorityQueue = function (capacity) {
|
567
|
+
this.items = new Array(capacity);
|
568
|
+
this.length = 0;
|
569
|
+
};
|
570
|
+
|
571
|
+
var priorityProto = PriorityQueue.prototype;
|
572
|
+
priorityProto.isHigherPriority = function (left, right) {
|
573
|
+
return this.items[left].compareTo(this.items[right]) < 0;
|
574
|
+
};
|
575
|
+
|
576
|
+
priorityProto.percolate = function (index) {
|
577
|
+
if (index >= this.length || index < 0) { return; }
|
578
|
+
var parent = index - 1 >> 1;
|
579
|
+
if (parent < 0 || parent === index) { return; }
|
580
|
+
if (this.isHigherPriority(index, parent)) {
|
581
|
+
var temp = this.items[index];
|
582
|
+
this.items[index] = this.items[parent];
|
583
|
+
this.items[parent] = temp;
|
584
|
+
this.percolate(parent);
|
585
|
+
}
|
586
|
+
};
|
587
|
+
|
588
|
+
priorityProto.heapify = function (index) {
|
589
|
+
+index || (index = 0);
|
590
|
+
if (index >= this.length || index < 0) { return; }
|
591
|
+
var left = 2 * index + 1,
|
592
|
+
right = 2 * index + 2,
|
593
|
+
first = index;
|
594
|
+
if (left < this.length && this.isHigherPriority(left, first)) {
|
595
|
+
first = left;
|
596
|
+
}
|
597
|
+
if (right < this.length && this.isHigherPriority(right, first)) {
|
598
|
+
first = right;
|
599
|
+
}
|
600
|
+
if (first !== index) {
|
601
|
+
var temp = this.items[index];
|
602
|
+
this.items[index] = this.items[first];
|
603
|
+
this.items[first] = temp;
|
604
|
+
this.heapify(first);
|
605
|
+
}
|
606
|
+
};
|
607
|
+
|
608
|
+
priorityProto.peek = function () { return this.items[0].value; };
|
609
|
+
|
610
|
+
priorityProto.removeAt = function (index) {
|
611
|
+
this.items[index] = this.items[--this.length];
|
612
|
+
delete this.items[this.length];
|
613
|
+
this.heapify();
|
614
|
+
};
|
615
|
+
|
616
|
+
priorityProto.dequeue = function () {
|
617
|
+
var result = this.peek();
|
618
|
+
this.removeAt(0);
|
619
|
+
return result;
|
620
|
+
};
|
621
|
+
|
622
|
+
priorityProto.enqueue = function (item) {
|
623
|
+
var index = this.length++;
|
624
|
+
this.items[index] = new IndexedItem(PriorityQueue.count++, item);
|
625
|
+
this.percolate(index);
|
626
|
+
};
|
627
|
+
|
628
|
+
priorityProto.remove = function (item) {
|
629
|
+
for (var i = 0; i < this.length; i++) {
|
630
|
+
if (this.items[i].value === item) {
|
631
|
+
this.removeAt(i);
|
632
|
+
return true;
|
633
|
+
}
|
634
|
+
}
|
635
|
+
return false;
|
636
|
+
};
|
637
637
|
PriorityQueue.count = 0;
|
638
|
+
|
638
639
|
/**
|
639
640
|
* Represents a group of disposable resources that are disposed together.
|
640
641
|
* @constructor
|
@@ -650,7 +651,7 @@ if (!Array.prototype.forEach) {
|
|
650
651
|
/**
|
651
652
|
* Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed.
|
652
653
|
* @param {Mixed} item Disposable to add.
|
653
|
-
*/
|
654
|
+
*/
|
654
655
|
CompositeDisposablePrototype.add = function (item) {
|
655
656
|
if (this.isDisposed) {
|
656
657
|
item.dispose();
|
@@ -680,7 +681,7 @@ if (!Array.prototype.forEach) {
|
|
680
681
|
};
|
681
682
|
|
682
683
|
/**
|
683
|
-
* Disposes all disposables in the group and removes them from the group.
|
684
|
+
* Disposes all disposables in the group and removes them from the group.
|
684
685
|
*/
|
685
686
|
CompositeDisposablePrototype.dispose = function () {
|
686
687
|
if (!this.isDisposed) {
|
@@ -698,15 +699,15 @@ if (!Array.prototype.forEach) {
|
|
698
699
|
/**
|
699
700
|
* Converts the existing CompositeDisposable to an array of disposables
|
700
701
|
* @returns {Array} An array of disposable objects.
|
701
|
-
*/
|
702
|
+
*/
|
702
703
|
CompositeDisposablePrototype.toArray = function () {
|
703
704
|
return this.disposables.slice(0);
|
704
705
|
};
|
705
|
-
|
706
|
+
|
706
707
|
/**
|
707
708
|
* Provides a set of static methods for creating Disposables.
|
708
709
|
*
|
709
|
-
* @constructor
|
710
|
+
* @constructor
|
710
711
|
* @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once.
|
711
712
|
*/
|
712
713
|
var Disposable = Rx.Disposable = function (action) {
|
@@ -714,7 +715,7 @@ if (!Array.prototype.forEach) {
|
|
714
715
|
this.action = action || noop;
|
715
716
|
};
|
716
717
|
|
717
|
-
/** Performs the task of cleaning up resources. */
|
718
|
+
/** Performs the task of cleaning up resources. */
|
718
719
|
Disposable.prototype.dispose = function () {
|
719
720
|
if (!this.isDisposed) {
|
720
721
|
this.action();
|
@@ -729,8 +730,8 @@ if (!Array.prototype.forEach) {
|
|
729
730
|
*/
|
730
731
|
var disposableCreate = Disposable.create = function (action) { return new Disposable(action); };
|
731
732
|
|
732
|
-
/**
|
733
|
-
* Gets the disposable that does nothing when disposed.
|
733
|
+
/**
|
734
|
+
* Gets the disposable that does nothing when disposed.
|
734
735
|
*/
|
735
736
|
var disposableEmpty = Disposable.empty = { dispose: noop };
|
736
737
|
|
@@ -753,7 +754,7 @@ if (!Array.prototype.forEach) {
|
|
753
754
|
/**
|
754
755
|
* Sets the underlying disposable.
|
755
756
|
* @param {Disposable} value The new underlying disposable.
|
756
|
-
*/
|
757
|
+
*/
|
757
758
|
booleanDisposablePrototype.setDisposable = function (value) {
|
758
759
|
var shouldDispose = this.isDisposed, old;
|
759
760
|
if (!shouldDispose) {
|
@@ -764,7 +765,7 @@ if (!Array.prototype.forEach) {
|
|
764
765
|
shouldDispose && value && value.dispose();
|
765
766
|
};
|
766
767
|
|
767
|
-
/**
|
768
|
+
/**
|
768
769
|
* Disposes the underlying disposable as well as all future replacements.
|
769
770
|
*/
|
770
771
|
booleanDisposablePrototype.dispose = function () {
|
@@ -780,9 +781,10 @@ if (!Array.prototype.forEach) {
|
|
780
781
|
return BooleanDisposable;
|
781
782
|
}());
|
782
783
|
var SerialDisposable = Rx.SerialDisposable = SingleAssignmentDisposable;
|
784
|
+
|
783
785
|
/**
|
784
786
|
* Represents a disposable resource that only disposes its underlying disposable resource when all dependent disposable objects have been disposed.
|
785
|
-
*/
|
787
|
+
*/
|
786
788
|
var RefCountDisposable = Rx.RefCountDisposable = (function () {
|
787
789
|
|
788
790
|
function InnerDisposable(disposable) {
|
@@ -816,8 +818,8 @@ if (!Array.prototype.forEach) {
|
|
816
818
|
this.count = 0;
|
817
819
|
}
|
818
820
|
|
819
|
-
/**
|
820
|
-
* Disposes the underlying disposable only when all dependent disposables have been disposed
|
821
|
+
/**
|
822
|
+
* Disposes the underlying disposable only when all dependent disposables have been disposed
|
821
823
|
*/
|
822
824
|
RefCountDisposable.prototype.dispose = function () {
|
823
825
|
if (!this.isDisposed) {
|
@@ -832,9 +834,9 @@ if (!Array.prototype.forEach) {
|
|
832
834
|
};
|
833
835
|
|
834
836
|
/**
|
835
|
-
* Returns a dependent disposable that when disposed decreases the refcount on the underlying disposable.
|
837
|
+
* Returns a dependent disposable that when disposed decreases the refcount on the underlying disposable.
|
836
838
|
* @returns {Disposable} A dependent disposable contributing to the reference count that manages the underlying disposable's lifetime.
|
837
|
-
*/
|
839
|
+
*/
|
838
840
|
RefCountDisposable.prototype.getDisposable = function () {
|
839
841
|
return this.isDisposed ? disposableEmpty : new InnerDisposable(this);
|
840
842
|
};
|
@@ -842,30 +844,30 @@ if (!Array.prototype.forEach) {
|
|
842
844
|
return RefCountDisposable;
|
843
845
|
})();
|
844
846
|
|
845
|
-
var ScheduledItem = Rx.internals.ScheduledItem = function (scheduler, state, action, dueTime, comparer) {
|
846
|
-
this.scheduler = scheduler;
|
847
|
-
this.state = state;
|
848
|
-
this.action = action;
|
849
|
-
this.dueTime = dueTime;
|
850
|
-
this.comparer = comparer || defaultSubComparer;
|
851
|
-
this.disposable = new SingleAssignmentDisposable();
|
852
|
-
}
|
853
|
-
|
854
|
-
ScheduledItem.prototype.invoke = function () {
|
855
|
-
this.disposable.setDisposable(this.invokeCore());
|
856
|
-
};
|
857
|
-
|
858
|
-
ScheduledItem.prototype.compareTo = function (other) {
|
859
|
-
return this.comparer(this.dueTime, other.dueTime);
|
860
|
-
};
|
861
|
-
|
862
|
-
ScheduledItem.prototype.isCancelled = function () {
|
863
|
-
return this.disposable.isDisposed;
|
864
|
-
};
|
865
|
-
|
866
|
-
ScheduledItem.prototype.invokeCore = function () {
|
867
|
-
return this.action(this.scheduler, this.state);
|
868
|
-
};
|
847
|
+
var ScheduledItem = Rx.internals.ScheduledItem = function (scheduler, state, action, dueTime, comparer) {
|
848
|
+
this.scheduler = scheduler;
|
849
|
+
this.state = state;
|
850
|
+
this.action = action;
|
851
|
+
this.dueTime = dueTime;
|
852
|
+
this.comparer = comparer || defaultSubComparer;
|
853
|
+
this.disposable = new SingleAssignmentDisposable();
|
854
|
+
}
|
855
|
+
|
856
|
+
ScheduledItem.prototype.invoke = function () {
|
857
|
+
this.disposable.setDisposable(this.invokeCore());
|
858
|
+
};
|
859
|
+
|
860
|
+
ScheduledItem.prototype.compareTo = function (other) {
|
861
|
+
return this.comparer(this.dueTime, other.dueTime);
|
862
|
+
};
|
863
|
+
|
864
|
+
ScheduledItem.prototype.isCancelled = function () {
|
865
|
+
return this.disposable.isDisposed;
|
866
|
+
};
|
867
|
+
|
868
|
+
ScheduledItem.prototype.invokeCore = function () {
|
869
|
+
return this.action(this.scheduler, this.state);
|
870
|
+
};
|
869
871
|
|
870
872
|
/** Provides a set of static properties to access commonly used schedulers. */
|
871
873
|
var Scheduler = Rx.Scheduler = (function () {
|
@@ -933,7 +935,7 @@ if (!Array.prototype.forEach) {
|
|
933
935
|
var schedulerProto = Scheduler.prototype;
|
934
936
|
|
935
937
|
/**
|
936
|
-
* Schedules an action to be executed.
|
938
|
+
* Schedules an action to be executed.
|
937
939
|
* @param {Function} action Action to execute.
|
938
940
|
* @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
|
939
941
|
*/
|
@@ -942,7 +944,7 @@ if (!Array.prototype.forEach) {
|
|
942
944
|
};
|
943
945
|
|
944
946
|
/**
|
945
|
-
* Schedules an action to be executed.
|
947
|
+
* Schedules an action to be executed.
|
946
948
|
* @param state State passed to the action to be executed.
|
947
949
|
* @param {Function} action Action to be executed.
|
948
950
|
* @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
|
@@ -952,7 +954,7 @@ if (!Array.prototype.forEach) {
|
|
952
954
|
};
|
953
955
|
|
954
956
|
/**
|
955
|
-
* Schedules an action to be executed after the specified relative due time.
|
957
|
+
* Schedules an action to be executed after the specified relative due time.
|
956
958
|
* @param {Function} action Action to execute.
|
957
959
|
* @param {Number} dueTime Relative time after which to execute the action.
|
958
960
|
* @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
|
@@ -962,7 +964,7 @@ if (!Array.prototype.forEach) {
|
|
962
964
|
};
|
963
965
|
|
964
966
|
/**
|
965
|
-
* Schedules an action to be executed after dueTime.
|
967
|
+
* Schedules an action to be executed after dueTime.
|
966
968
|
* @param state State passed to the action to be executed.
|
967
969
|
* @param {Function} action Action to be executed.
|
968
970
|
* @param {Number} dueTime Relative time after which to execute the action.
|
@@ -973,7 +975,7 @@ if (!Array.prototype.forEach) {
|
|
973
975
|
};
|
974
976
|
|
975
977
|
/**
|
976
|
-
* Schedules an action to be executed at the specified absolute due time.
|
978
|
+
* Schedules an action to be executed at the specified absolute due time.
|
977
979
|
* @param {Function} action Action to execute.
|
978
980
|
* @param {Number} dueTime Absolute time at which to execute the action.
|
979
981
|
* @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
|
@@ -983,7 +985,7 @@ if (!Array.prototype.forEach) {
|
|
983
985
|
};
|
984
986
|
|
985
987
|
/**
|
986
|
-
* Schedules an action to be executed at dueTime.
|
988
|
+
* Schedules an action to be executed at dueTime.
|
987
989
|
* @param {Mixed} state State passed to the action to be executed.
|
988
990
|
* @param {Function} action Action to be executed.
|
989
991
|
* @param {Number}dueTime Absolute time at which to execute the action.
|
@@ -1000,7 +1002,7 @@ if (!Array.prototype.forEach) {
|
|
1000
1002
|
* Normalizes the specified TimeSpan value to a positive value.
|
1001
1003
|
* @param {Number} timeSpan The time span value to normalize.
|
1002
1004
|
* @returns {Number} The specified TimeSpan value if it is zero or positive; otherwise, 0
|
1003
|
-
*/
|
1005
|
+
*/
|
1004
1006
|
Scheduler.normalize = function (timeSpan) {
|
1005
1007
|
timeSpan < 0 && (timeSpan = 0);
|
1006
1008
|
return timeSpan;
|
@@ -1010,7 +1012,7 @@ if (!Array.prototype.forEach) {
|
|
1010
1012
|
}());
|
1011
1013
|
|
1012
1014
|
var normalizeTime = Scheduler.normalize;
|
1013
|
-
|
1015
|
+
|
1014
1016
|
(function (schedulerProto) {
|
1015
1017
|
function invokeRecImmediate(scheduler, pair) {
|
1016
1018
|
var state = pair.first, action = pair.second, group = new CompositeDisposable(),
|
@@ -1075,7 +1077,7 @@ if (!Array.prototype.forEach) {
|
|
1075
1077
|
};
|
1076
1078
|
|
1077
1079
|
/**
|
1078
|
-
* Schedules an action to be executed recursively.
|
1080
|
+
* Schedules an action to be executed recursively.
|
1079
1081
|
* @param {Mixed} state State passed to the action to be executed.
|
1080
1082
|
* @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.
|
1081
1083
|
* @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
|
@@ -1085,7 +1087,7 @@ if (!Array.prototype.forEach) {
|
|
1085
1087
|
};
|
1086
1088
|
|
1087
1089
|
/**
|
1088
|
-
* Schedules an action to be executed recursively after a specified relative due time.
|
1090
|
+
* Schedules an action to be executed recursively after a specified relative due time.
|
1089
1091
|
* @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.
|
1090
1092
|
* @param {Number}dueTime Relative time after which to execute the action for the first time.
|
1091
1093
|
* @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
|
@@ -1095,7 +1097,7 @@ if (!Array.prototype.forEach) {
|
|
1095
1097
|
};
|
1096
1098
|
|
1097
1099
|
/**
|
1098
|
-
* Schedules an action to be executed recursively after a specified relative due time.
|
1100
|
+
* Schedules an action to be executed recursively after a specified relative due time.
|
1099
1101
|
* @param {Mixed} state State passed to the action to be executed.
|
1100
1102
|
* @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.
|
1101
1103
|
* @param {Number}dueTime Relative time after which to execute the action for the first time.
|
@@ -1108,7 +1110,7 @@ if (!Array.prototype.forEach) {
|
|
1108
1110
|
};
|
1109
1111
|
|
1110
1112
|
/**
|
1111
|
-
* Schedules an action to be executed recursively at a specified absolute due time.
|
1113
|
+
* Schedules an action to be executed recursively at a specified absolute due time.
|
1112
1114
|
* @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.
|
1113
1115
|
* @param {Number}dueTime Absolute time at which to execute the action for the first time.
|
1114
1116
|
* @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
|
@@ -1118,7 +1120,7 @@ if (!Array.prototype.forEach) {
|
|
1118
1120
|
};
|
1119
1121
|
|
1120
1122
|
/**
|
1121
|
-
* Schedules an action to be executed recursively at a specified absolute due time.
|
1123
|
+
* Schedules an action to be executed recursively at a specified absolute due time.
|
1122
1124
|
* @param {Mixed} state State passed to the action to be executed.
|
1123
1125
|
* @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.
|
1124
1126
|
* @param {Number}dueTime Absolute time at which to execute the action for the first time.
|
@@ -1128,23 +1130,23 @@ if (!Array.prototype.forEach) {
|
|
1128
1130
|
return this._scheduleAbsolute({ first: state, second: action }, dueTime, function (s, p) {
|
1129
1131
|
return invokeRecDate(s, p, 'scheduleWithAbsoluteAndState');
|
1130
1132
|
});
|
1131
|
-
};
|
1133
|
+
};
|
1132
1134
|
}(Scheduler.prototype));
|
1133
1135
|
|
1134
1136
|
(function (schedulerProto) {
|
1135
1137
|
|
1136
1138
|
/**
|
1137
|
-
* 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.
|
1139
|
+
* 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.
|
1138
1140
|
* @param {Number} period Period for running the work periodically.
|
1139
1141
|
* @param {Function} action Action to be executed.
|
1140
1142
|
* @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort).
|
1141
|
-
*/
|
1143
|
+
*/
|
1142
1144
|
Scheduler.prototype.schedulePeriodic = function (period, action) {
|
1143
1145
|
return this.schedulePeriodicWithState(null, period, action);
|
1144
1146
|
};
|
1145
1147
|
|
1146
1148
|
/**
|
1147
|
-
* 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.
|
1149
|
+
* 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.
|
1148
1150
|
* @param {Mixed} state Initial state passed to the action upon the first iteration.
|
1149
1151
|
* @param {Number} period Period for running the work periodically.
|
1150
1152
|
* @param {Function} action Action to be executed, potentially updating the state.
|
@@ -1153,7 +1155,7 @@ if (!Array.prototype.forEach) {
|
|
1153
1155
|
Scheduler.prototype.schedulePeriodicWithState = function(state, period, action) {
|
1154
1156
|
if (typeof root.setInterval === 'undefined') { throw new Error('Periodic scheduling not supported.'); }
|
1155
1157
|
var s = state;
|
1156
|
-
|
1158
|
+
|
1157
1159
|
var id = root.setInterval(function () {
|
1158
1160
|
s = action(s);
|
1159
1161
|
}, period);
|
@@ -1164,28 +1166,28 @@ if (!Array.prototype.forEach) {
|
|
1164
1166
|
};
|
1165
1167
|
|
1166
1168
|
}(Scheduler.prototype));
|
1167
|
-
|
1168
|
-
/**
|
1169
|
-
* Gets a scheduler that schedules work immediately on the current thread.
|
1170
|
-
*/
|
1171
|
-
var immediateScheduler = Scheduler.immediate = (function () {
|
1172
|
-
|
1173
|
-
function scheduleNow(state, action) { return action(this, state); }
|
1174
|
-
|
1175
|
-
function scheduleRelative(state, dueTime, action) {
|
1176
|
-
var dt = normalizeTime(dt);
|
1177
|
-
while (dt - this.now() > 0) { }
|
1178
|
-
return action(this, state);
|
1179
|
-
}
|
1180
|
-
|
1181
|
-
function scheduleAbsolute(state, dueTime, action) {
|
1182
|
-
return this.scheduleWithRelativeAndState(state, dueTime - this.now(), action);
|
1183
|
-
}
|
1184
|
-
|
1185
|
-
return new Scheduler(defaultNow, scheduleNow, scheduleRelative, scheduleAbsolute);
|
1186
|
-
}());
|
1187
|
-
|
1188
|
-
/**
|
1169
|
+
|
1170
|
+
/**
|
1171
|
+
* Gets a scheduler that schedules work immediately on the current thread.
|
1172
|
+
*/
|
1173
|
+
var immediateScheduler = Scheduler.immediate = (function () {
|
1174
|
+
|
1175
|
+
function scheduleNow(state, action) { return action(this, state); }
|
1176
|
+
|
1177
|
+
function scheduleRelative(state, dueTime, action) {
|
1178
|
+
var dt = normalizeTime(dt);
|
1179
|
+
while (dt - this.now() > 0) { }
|
1180
|
+
return action(this, state);
|
1181
|
+
}
|
1182
|
+
|
1183
|
+
function scheduleAbsolute(state, dueTime, action) {
|
1184
|
+
return this.scheduleWithRelativeAndState(state, dueTime - this.now(), action);
|
1185
|
+
}
|
1186
|
+
|
1187
|
+
return new Scheduler(defaultNow, scheduleNow, scheduleRelative, scheduleAbsolute);
|
1188
|
+
}());
|
1189
|
+
|
1190
|
+
/**
|
1189
1191
|
* Gets a scheduler that schedules work as soon as possible on the current thread.
|
1190
1192
|
*/
|
1191
1193
|
var currentThreadScheduler = Scheduler.currentThread = (function () {
|
@@ -1219,7 +1221,7 @@ if (!Array.prototype.forEach) {
|
|
1219
1221
|
queue.enqueue(si);
|
1220
1222
|
try {
|
1221
1223
|
runTrampoline(queue);
|
1222
|
-
} catch (e) {
|
1224
|
+
} catch (e) {
|
1223
1225
|
throw e;
|
1224
1226
|
} finally {
|
1225
1227
|
queue = null;
|
@@ -1235,7 +1237,7 @@ if (!Array.prototype.forEach) {
|
|
1235
1237
|
}
|
1236
1238
|
|
1237
1239
|
var currentScheduler = new Scheduler(defaultNow, scheduleNow, scheduleRelative, scheduleAbsolute);
|
1238
|
-
|
1240
|
+
|
1239
1241
|
currentScheduler.scheduleRequired = function () { return !queue; };
|
1240
1242
|
currentScheduler.ensureTrampoline = function (action) {
|
1241
1243
|
if (!queue) { this.schedule(action); } else { action(); }
|
@@ -1244,34 +1246,34 @@ if (!Array.prototype.forEach) {
|
|
1244
1246
|
return currentScheduler;
|
1245
1247
|
}());
|
1246
1248
|
|
1247
|
-
var SchedulePeriodicRecursive = Rx.internals.SchedulePeriodicRecursive = (function () {
|
1248
|
-
function tick(command, recurse) {
|
1249
|
-
recurse(0, this._period);
|
1250
|
-
try {
|
1251
|
-
this._state = this._action(this._state);
|
1252
|
-
} catch (e) {
|
1253
|
-
this._cancel.dispose();
|
1254
|
-
throw e;
|
1255
|
-
}
|
1256
|
-
}
|
1257
|
-
|
1258
|
-
function SchedulePeriodicRecursive(scheduler, state, period, action) {
|
1259
|
-
this._scheduler = scheduler;
|
1260
|
-
this._state = state;
|
1261
|
-
this._period = period;
|
1262
|
-
this._action = action;
|
1263
|
-
}
|
1264
|
-
|
1265
|
-
SchedulePeriodicRecursive.prototype.start = function () {
|
1266
|
-
var d = new SingleAssignmentDisposable();
|
1267
|
-
this._cancel = d;
|
1268
|
-
d.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0, this._period, tick.bind(this)));
|
1269
|
-
|
1270
|
-
return d;
|
1271
|
-
};
|
1272
|
-
|
1273
|
-
return SchedulePeriodicRecursive;
|
1274
|
-
}());
|
1249
|
+
var SchedulePeriodicRecursive = Rx.internals.SchedulePeriodicRecursive = (function () {
|
1250
|
+
function tick(command, recurse) {
|
1251
|
+
recurse(0, this._period);
|
1252
|
+
try {
|
1253
|
+
this._state = this._action(this._state);
|
1254
|
+
} catch (e) {
|
1255
|
+
this._cancel.dispose();
|
1256
|
+
throw e;
|
1257
|
+
}
|
1258
|
+
}
|
1259
|
+
|
1260
|
+
function SchedulePeriodicRecursive(scheduler, state, period, action) {
|
1261
|
+
this._scheduler = scheduler;
|
1262
|
+
this._state = state;
|
1263
|
+
this._period = period;
|
1264
|
+
this._action = action;
|
1265
|
+
}
|
1266
|
+
|
1267
|
+
SchedulePeriodicRecursive.prototype.start = function () {
|
1268
|
+
var d = new SingleAssignmentDisposable();
|
1269
|
+
this._cancel = d;
|
1270
|
+
d.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0, this._period, tick.bind(this)));
|
1271
|
+
|
1272
|
+
return d;
|
1273
|
+
};
|
1274
|
+
|
1275
|
+
return SchedulePeriodicRecursive;
|
1276
|
+
}());
|
1275
1277
|
|
1276
1278
|
var scheduleMethod, clearMethod = noop;
|
1277
1279
|
var localTimer = (function () {
|
@@ -1292,11 +1294,11 @@ if (!Array.prototype.forEach) {
|
|
1292
1294
|
setTimeout: localSetTimeout,
|
1293
1295
|
clearTimeout: localClearTimeout
|
1294
1296
|
};
|
1295
|
-
}());
|
1297
|
+
}());
|
1296
1298
|
var localSetTimeout = localTimer.setTimeout,
|
1297
1299
|
localClearTimeout = localTimer.clearTimeout;
|
1298
1300
|
|
1299
|
-
(function () {
|
1301
|
+
(function () {
|
1300
1302
|
|
1301
1303
|
var reNative = RegExp('^' +
|
1302
1304
|
String(toString)
|
@@ -1312,7 +1314,7 @@ if (!Array.prototype.forEach) {
|
|
1312
1314
|
function postMessageSupported () {
|
1313
1315
|
// Ensure not in a worker
|
1314
1316
|
if (!root.postMessage || root.importScripts) { return false; }
|
1315
|
-
var isAsync = false,
|
1317
|
+
var isAsync = false,
|
1316
1318
|
oldHandler = root.onmessage;
|
1317
1319
|
// Test for async
|
1318
1320
|
root.onmessage = function () { isAsync = true; };
|
@@ -1369,19 +1371,19 @@ if (!Array.prototype.forEach) {
|
|
1369
1371
|
scheduleMethod = function (action) {
|
1370
1372
|
var id = channelTaskId++;
|
1371
1373
|
channelTasks[id] = action;
|
1372
|
-
channel.port2.postMessage(id);
|
1374
|
+
channel.port2.postMessage(id);
|
1373
1375
|
};
|
1374
1376
|
} else if ('document' in root && 'onreadystatechange' in root.document.createElement('script')) {
|
1375
|
-
|
1377
|
+
|
1376
1378
|
scheduleMethod = function (action) {
|
1377
1379
|
var scriptElement = root.document.createElement('script');
|
1378
|
-
scriptElement.onreadystatechange = function () {
|
1380
|
+
scriptElement.onreadystatechange = function () {
|
1379
1381
|
action();
|
1380
1382
|
scriptElement.onreadystatechange = null;
|
1381
1383
|
scriptElement.parentNode.removeChild(scriptElement);
|
1382
|
-
scriptElement = null;
|
1384
|
+
scriptElement = null;
|
1383
1385
|
};
|
1384
|
-
root.document.documentElement.appendChild(scriptElement);
|
1386
|
+
root.document.documentElement.appendChild(scriptElement);
|
1385
1387
|
};
|
1386
1388
|
|
1387
1389
|
} else {
|
@@ -1390,7 +1392,7 @@ if (!Array.prototype.forEach) {
|
|
1390
1392
|
}
|
1391
1393
|
}());
|
1392
1394
|
|
1393
|
-
/**
|
1395
|
+
/**
|
1394
1396
|
* Gets a scheduler that schedules work via a timed callback based upon platform.
|
1395
1397
|
*/
|
1396
1398
|
var timeoutScheduler = Scheduler.timeout = (function () {
|
@@ -1436,14 +1438,14 @@ if (!Array.prototype.forEach) {
|
|
1436
1438
|
* Represents a notification to an observer.
|
1437
1439
|
*/
|
1438
1440
|
var Notification = Rx.Notification = (function () {
|
1439
|
-
function Notification(kind, hasValue) {
|
1441
|
+
function Notification(kind, hasValue) {
|
1440
1442
|
this.hasValue = hasValue == null ? false : hasValue;
|
1441
1443
|
this.kind = kind;
|
1442
1444
|
}
|
1443
1445
|
|
1444
1446
|
/**
|
1445
1447
|
* Invokes the delegate corresponding to the notification or the observer's method corresponding to the notification and returns the produced result.
|
1446
|
-
*
|
1448
|
+
*
|
1447
1449
|
* @memberOf Notification
|
1448
1450
|
* @param {Any} observerOrOnNext Delegate to invoke for an OnNext notification or Observer to invoke the notification on..
|
1449
1451
|
* @param {Function} onError Delegate to invoke for an OnError notification.
|
@@ -1458,7 +1460,7 @@ if (!Array.prototype.forEach) {
|
|
1458
1460
|
|
1459
1461
|
/**
|
1460
1462
|
* Returns an observable sequence with a single notification.
|
1461
|
-
*
|
1463
|
+
*
|
1462
1464
|
* @memberOf Notifications
|
1463
1465
|
* @param {Scheduler} [scheduler] Scheduler to send out the notification calls on.
|
1464
1466
|
* @returns {Observable} The observable sequence that surfaces the behavior of the notification upon subscription.
|
@@ -1538,299 +1540,280 @@ if (!Array.prototype.forEach) {
|
|
1538
1540
|
};
|
1539
1541
|
}());
|
1540
1542
|
|
1541
|
-
var Enumerator = Rx.internals.Enumerator = function (next) {
|
1542
|
-
this._next = next;
|
1543
|
-
};
|
1544
|
-
|
1545
|
-
Enumerator.prototype.next = function () {
|
1546
|
-
return this._next();
|
1547
|
-
};
|
1548
|
-
|
1549
|
-
Enumerator.prototype[$iterator$] = function () { return this; }
|
1550
|
-
|
1551
|
-
var Enumerable = Rx.internals.Enumerable = function (iterator) {
|
1552
|
-
this._iterator = iterator;
|
1553
|
-
};
|
1554
|
-
|
1555
|
-
Enumerable.prototype[$iterator$] = function () {
|
1556
|
-
return this._iterator();
|
1557
|
-
};
|
1558
|
-
|
1559
|
-
Enumerable.prototype.concat = function () {
|
1560
|
-
var sources = this;
|
1561
|
-
return new AnonymousObservable(function (observer) {
|
1562
|
-
var e;
|
1563
|
-
try {
|
1564
|
-
e = sources[$iterator$]();
|
1565
|
-
} catch(err) {
|
1566
|
-
observer.onError();
|
1567
|
-
return;
|
1568
|
-
}
|
1569
|
-
|
1570
|
-
var isDisposed,
|
1571
|
-
subscription = new SerialDisposable();
|
1572
|
-
var cancelable = immediateScheduler.scheduleRecursive(function (self) {
|
1573
|
-
var currentItem;
|
1574
|
-
if (isDisposed) { return; }
|
1575
|
-
|
1576
|
-
try {
|
1577
|
-
currentItem = e.next();
|
1578
|
-
} catch (ex) {
|
1579
|
-
observer.onError(ex);
|
1580
|
-
return;
|
1581
|
-
}
|
1582
|
-
|
1583
|
-
if (currentItem.done) {
|
1584
|
-
observer.onCompleted();
|
1585
|
-
return;
|
1586
|
-
}
|
1587
|
-
|
1588
|
-
// Check if promise
|
1589
|
-
var currentValue = currentItem.value;
|
1590
|
-
isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));
|
1591
|
-
|
1592
|
-
var d = new SingleAssignmentDisposable();
|
1593
|
-
subscription.setDisposable(d);
|
1594
|
-
d.setDisposable(currentValue.subscribe(
|
1595
|
-
observer.onNext.bind(observer),
|
1596
|
-
observer.onError.bind(observer),
|
1597
|
-
function () { self(); })
|
1598
|
-
);
|
1599
|
-
});
|
1600
|
-
|
1601
|
-
return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {
|
1602
|
-
isDisposed = true;
|
1603
|
-
}));
|
1604
|
-
});
|
1605
|
-
};
|
1606
|
-
|
1607
|
-
Enumerable.prototype.catchException = function () {
|
1608
|
-
var sources = this;
|
1609
|
-
return new AnonymousObservable(function (observer) {
|
1610
|
-
var e;
|
1611
|
-
try {
|
1612
|
-
e = sources[$iterator$]();
|
1613
|
-
} catch(err) {
|
1614
|
-
observer.onError();
|
1615
|
-
return;
|
1616
|
-
}
|
1617
|
-
|
1618
|
-
var isDisposed,
|
1619
|
-
lastException,
|
1620
|
-
subscription = new SerialDisposable();
|
1621
|
-
var cancelable = immediateScheduler.scheduleRecursive(function (self) {
|
1622
|
-
if (isDisposed) { return; }
|
1623
|
-
|
1624
|
-
var currentItem;
|
1625
|
-
try {
|
1626
|
-
currentItem = e.next();
|
1627
|
-
} catch (ex) {
|
1628
|
-
observer.onError(ex);
|
1629
|
-
return;
|
1630
|
-
}
|
1631
|
-
|
1632
|
-
if (currentItem.done) {
|
1633
|
-
if (lastException) {
|
1634
|
-
observer.onError(lastException);
|
1635
|
-
} else {
|
1636
|
-
observer.onCompleted();
|
1637
|
-
}
|
1638
|
-
return;
|
1639
|
-
}
|
1640
|
-
|
1641
|
-
// Check if promise
|
1642
|
-
var currentValue = currentItem.value;
|
1643
|
-
isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));
|
1644
|
-
|
1645
|
-
var d = new SingleAssignmentDisposable();
|
1646
|
-
subscription.setDisposable(d);
|
1647
|
-
d.setDisposable(currentValue.subscribe(
|
1648
|
-
observer.onNext.bind(observer),
|
1649
|
-
function (exn) {
|
1650
|
-
lastException = exn;
|
1651
|
-
self();
|
1652
|
-
},
|
1653
|
-
observer.onCompleted.bind(observer)));
|
1654
|
-
});
|
1655
|
-
return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {
|
1656
|
-
isDisposed = true;
|
1657
|
-
}));
|
1658
|
-
});
|
1659
|
-
};
|
1660
|
-
|
1661
|
-
var enumerableRepeat = Enumerable.repeat = function (value, repeatCount) {
|
1662
|
-
if (repeatCount == null) { repeatCount = -1; }
|
1663
|
-
return new Enumerable(function () {
|
1664
|
-
var left = repeatCount;
|
1665
|
-
return new Enumerator(function () {
|
1666
|
-
if (left === 0) { return doneEnumerator; }
|
1667
|
-
if (left > 0) { left--; }
|
1668
|
-
return { done: false, value: value };
|
1669
|
-
});
|
1670
|
-
});
|
1671
|
-
};
|
1672
|
-
|
1673
|
-
var
|
1674
|
-
selector || (selector = identity);
|
1675
|
-
return new Enumerable(function () {
|
1676
|
-
var index = -1;
|
1677
|
-
return new Enumerator(
|
1678
|
-
function () {
|
1679
|
-
return ++index < source.length ?
|
1680
|
-
{ done: false, value: selector.call(thisArg, source[index], index, source) } :
|
1681
|
-
doneEnumerator;
|
1682
|
-
});
|
1683
|
-
});
|
1684
|
-
};
|
1543
|
+
var Enumerator = Rx.internals.Enumerator = function (next) {
|
1544
|
+
this._next = next;
|
1545
|
+
};
|
1546
|
+
|
1547
|
+
Enumerator.prototype.next = function () {
|
1548
|
+
return this._next();
|
1549
|
+
};
|
1550
|
+
|
1551
|
+
Enumerator.prototype[$iterator$] = function () { return this; }
|
1552
|
+
|
1553
|
+
var Enumerable = Rx.internals.Enumerable = function (iterator) {
|
1554
|
+
this._iterator = iterator;
|
1555
|
+
};
|
1556
|
+
|
1557
|
+
Enumerable.prototype[$iterator$] = function () {
|
1558
|
+
return this._iterator();
|
1559
|
+
};
|
1560
|
+
|
1561
|
+
Enumerable.prototype.concat = function () {
|
1562
|
+
var sources = this;
|
1563
|
+
return new AnonymousObservable(function (observer) {
|
1564
|
+
var e;
|
1565
|
+
try {
|
1566
|
+
e = sources[$iterator$]();
|
1567
|
+
} catch(err) {
|
1568
|
+
observer.onError();
|
1569
|
+
return;
|
1570
|
+
}
|
1571
|
+
|
1572
|
+
var isDisposed,
|
1573
|
+
subscription = new SerialDisposable();
|
1574
|
+
var cancelable = immediateScheduler.scheduleRecursive(function (self) {
|
1575
|
+
var currentItem;
|
1576
|
+
if (isDisposed) { return; }
|
1577
|
+
|
1578
|
+
try {
|
1579
|
+
currentItem = e.next();
|
1580
|
+
} catch (ex) {
|
1581
|
+
observer.onError(ex);
|
1582
|
+
return;
|
1583
|
+
}
|
1584
|
+
|
1585
|
+
if (currentItem.done) {
|
1586
|
+
observer.onCompleted();
|
1587
|
+
return;
|
1588
|
+
}
|
1589
|
+
|
1590
|
+
// Check if promise
|
1591
|
+
var currentValue = currentItem.value;
|
1592
|
+
isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));
|
1593
|
+
|
1594
|
+
var d = new SingleAssignmentDisposable();
|
1595
|
+
subscription.setDisposable(d);
|
1596
|
+
d.setDisposable(currentValue.subscribe(
|
1597
|
+
observer.onNext.bind(observer),
|
1598
|
+
observer.onError.bind(observer),
|
1599
|
+
function () { self(); })
|
1600
|
+
);
|
1601
|
+
});
|
1602
|
+
|
1603
|
+
return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {
|
1604
|
+
isDisposed = true;
|
1605
|
+
}));
|
1606
|
+
});
|
1607
|
+
};
|
1608
|
+
|
1609
|
+
Enumerable.prototype.catchException = function () {
|
1610
|
+
var sources = this;
|
1611
|
+
return new AnonymousObservable(function (observer) {
|
1612
|
+
var e;
|
1613
|
+
try {
|
1614
|
+
e = sources[$iterator$]();
|
1615
|
+
} catch(err) {
|
1616
|
+
observer.onError();
|
1617
|
+
return;
|
1618
|
+
}
|
1619
|
+
|
1620
|
+
var isDisposed,
|
1621
|
+
lastException,
|
1622
|
+
subscription = new SerialDisposable();
|
1623
|
+
var cancelable = immediateScheduler.scheduleRecursive(function (self) {
|
1624
|
+
if (isDisposed) { return; }
|
1625
|
+
|
1626
|
+
var currentItem;
|
1627
|
+
try {
|
1628
|
+
currentItem = e.next();
|
1629
|
+
} catch (ex) {
|
1630
|
+
observer.onError(ex);
|
1631
|
+
return;
|
1632
|
+
}
|
1633
|
+
|
1634
|
+
if (currentItem.done) {
|
1635
|
+
if (lastException) {
|
1636
|
+
observer.onError(lastException);
|
1637
|
+
} else {
|
1638
|
+
observer.onCompleted();
|
1639
|
+
}
|
1640
|
+
return;
|
1641
|
+
}
|
1642
|
+
|
1643
|
+
// Check if promise
|
1644
|
+
var currentValue = currentItem.value;
|
1645
|
+
isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));
|
1646
|
+
|
1647
|
+
var d = new SingleAssignmentDisposable();
|
1648
|
+
subscription.setDisposable(d);
|
1649
|
+
d.setDisposable(currentValue.subscribe(
|
1650
|
+
observer.onNext.bind(observer),
|
1651
|
+
function (exn) {
|
1652
|
+
lastException = exn;
|
1653
|
+
self();
|
1654
|
+
},
|
1655
|
+
observer.onCompleted.bind(observer)));
|
1656
|
+
});
|
1657
|
+
return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {
|
1658
|
+
isDisposed = true;
|
1659
|
+
}));
|
1660
|
+
});
|
1661
|
+
};
|
1662
|
+
|
1663
|
+
var enumerableRepeat = Enumerable.repeat = function (value, repeatCount) {
|
1664
|
+
if (repeatCount == null) { repeatCount = -1; }
|
1665
|
+
return new Enumerable(function () {
|
1666
|
+
var left = repeatCount;
|
1667
|
+
return new Enumerator(function () {
|
1668
|
+
if (left === 0) { return doneEnumerator; }
|
1669
|
+
if (left > 0) { left--; }
|
1670
|
+
return { done: false, value: value };
|
1671
|
+
});
|
1672
|
+
});
|
1673
|
+
};
|
1674
|
+
|
1675
|
+
var enumerableOf = Enumerable.of = function (source, selector, thisArg) {
|
1676
|
+
selector || (selector = identity);
|
1677
|
+
return new Enumerable(function () {
|
1678
|
+
var index = -1;
|
1679
|
+
return new Enumerator(
|
1680
|
+
function () {
|
1681
|
+
return ++index < source.length ?
|
1682
|
+
{ done: false, value: selector.call(thisArg, source[index], index, source) } :
|
1683
|
+
doneEnumerator;
|
1684
|
+
});
|
1685
|
+
});
|
1686
|
+
};
|
1687
|
+
|
1688
|
+
/**
|
1689
|
+
* Supports push-style iteration over an observable sequence.
|
1690
|
+
*/
|
1691
|
+
var Observer = Rx.Observer = function () { };
|
1692
|
+
|
1693
|
+
/**
|
1694
|
+
* Creates a notification callback from an observer.
|
1695
|
+
* @returns The action that forwards its input notification to the underlying observer.
|
1696
|
+
*/
|
1697
|
+
Observer.prototype.toNotifier = function () {
|
1698
|
+
var observer = this;
|
1699
|
+
return function (n) { return n.accept(observer); };
|
1700
|
+
};
|
1701
|
+
|
1702
|
+
/**
|
1703
|
+
* Hides the identity of an observer.
|
1704
|
+
* @returns An observer that hides the identity of the specified observer.
|
1705
|
+
*/
|
1706
|
+
Observer.prototype.asObserver = function () {
|
1707
|
+
return new AnonymousObserver(this.onNext.bind(this), this.onError.bind(this), this.onCompleted.bind(this));
|
1708
|
+
};
|
1709
|
+
|
1710
|
+
/**
|
1711
|
+
* Creates an observer from the specified OnNext, along with optional OnError, and OnCompleted actions.
|
1712
|
+
* @param {Function} [onNext] Observer's OnNext action implementation.
|
1713
|
+
* @param {Function} [onError] Observer's OnError action implementation.
|
1714
|
+
* @param {Function} [onCompleted] Observer's OnCompleted action implementation.
|
1715
|
+
* @returns {Observer} The observer object implemented using the given actions.
|
1716
|
+
*/
|
1717
|
+
var observerCreate = Observer.create = function (onNext, onError, onCompleted) {
|
1718
|
+
onNext || (onNext = noop);
|
1719
|
+
onError || (onError = defaultError);
|
1720
|
+
onCompleted || (onCompleted = noop);
|
1721
|
+
return new AnonymousObserver(onNext, onError, onCompleted);
|
1722
|
+
};
|
1723
|
+
|
1724
|
+
/**
|
1725
|
+
* Creates an observer from a notification callback.
|
1726
|
+
* @param {Function} handler Action that handles a notification.
|
1727
|
+
* @returns The observer object that invokes the specified handler using a notification corresponding to each message it receives.
|
1728
|
+
*/
|
1729
|
+
Observer.fromNotifier = function (handler, thisArg) {
|
1730
|
+
return new AnonymousObserver(function (x) {
|
1731
|
+
return handler.call(thisArg, notificationCreateOnNext(x));
|
1732
|
+
}, function (e) {
|
1733
|
+
return handler.call(thisArg, notificationCreateOnError(e));
|
1734
|
+
}, function () {
|
1735
|
+
return handler.call(thisArg, notificationCreateOnCompleted());
|
1736
|
+
});
|
1737
|
+
};
|
1738
|
+
|
1739
|
+
/**
|
1740
|
+
* Abstract base class for implementations of the Observer class.
|
1741
|
+
* This base class enforces the grammar of observers where OnError and OnCompleted are terminal messages.
|
1742
|
+
*/
|
1743
|
+
var AbstractObserver = Rx.internals.AbstractObserver = (function (__super__) {
|
1744
|
+
inherits(AbstractObserver, __super__);
|
1685
1745
|
|
1686
1746
|
/**
|
1687
|
-
*
|
1747
|
+
* Creates a new observer in a non-stopped state.
|
1688
1748
|
*/
|
1689
|
-
|
1749
|
+
function AbstractObserver() {
|
1750
|
+
this.isStopped = false;
|
1751
|
+
__super__.call(this);
|
1752
|
+
}
|
1690
1753
|
|
1691
1754
|
/**
|
1692
|
-
*
|
1693
|
-
*
|
1694
|
-
* @param observer Observer object.
|
1695
|
-
* @returns The action that forwards its input notification to the underlying observer.
|
1755
|
+
* Notifies the observer of a new element in the sequence.
|
1756
|
+
* @param {Any} value Next element in the sequence.
|
1696
1757
|
*/
|
1697
|
-
|
1698
|
-
|
1699
|
-
return function (n) {
|
1700
|
-
return n.accept(observer);
|
1701
|
-
};
|
1758
|
+
AbstractObserver.prototype.onNext = function (value) {
|
1759
|
+
if (!this.isStopped) { this.next(value); }
|
1702
1760
|
};
|
1703
1761
|
|
1704
1762
|
/**
|
1705
|
-
*
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1763
|
+
* Notifies the observer that an exception has occurred.
|
1764
|
+
* @param {Any} error The error that has occurred.
|
1765
|
+
*/
|
1766
|
+
AbstractObserver.prototype.onError = function (error) {
|
1767
|
+
if (!this.isStopped) {
|
1768
|
+
this.isStopped = true;
|
1769
|
+
this.error(error);
|
1770
|
+
}
|
1711
1771
|
};
|
1712
1772
|
|
1713
1773
|
/**
|
1714
|
-
*
|
1715
|
-
*
|
1716
|
-
* @static
|
1717
|
-
* @memberOf Observer
|
1718
|
-
* @param {Function} [onNext] Observer's OnNext action implementation.
|
1719
|
-
* @param {Function} [onError] Observer's OnError action implementation.
|
1720
|
-
* @param {Function} [onCompleted] Observer's OnCompleted action implementation.
|
1721
|
-
* @returns {Observer} The observer object implemented using the given actions.
|
1774
|
+
* Notifies the observer of the end of the sequence.
|
1722
1775
|
*/
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1776
|
+
AbstractObserver.prototype.onCompleted = function () {
|
1777
|
+
if (!this.isStopped) {
|
1778
|
+
this.isStopped = true;
|
1779
|
+
this.completed();
|
1780
|
+
}
|
1728
1781
|
};
|
1729
1782
|
|
1730
1783
|
/**
|
1731
|
-
*
|
1732
|
-
*
|
1733
|
-
* @static
|
1734
|
-
* @memberOf Observer
|
1735
|
-
* @param {Function} handler Action that handles a notification.
|
1736
|
-
* @returns The observer object that invokes the specified handler using a notification corresponding to each message it receives.
|
1784
|
+
* Disposes the observer, causing it to transition to the stopped state.
|
1737
1785
|
*/
|
1738
|
-
|
1739
|
-
|
1740
|
-
return handler(notificationCreateOnNext(x));
|
1741
|
-
}, function (exception) {
|
1742
|
-
return handler(notificationCreateOnError(exception));
|
1743
|
-
}, function () {
|
1744
|
-
return handler(notificationCreateOnCompleted());
|
1745
|
-
});
|
1786
|
+
AbstractObserver.prototype.dispose = function () {
|
1787
|
+
this.isStopped = true;
|
1746
1788
|
};
|
1747
|
-
|
1748
|
-
/**
|
1749
|
-
* Abstract base class for implementations of the Observer class.
|
1750
|
-
* This base class enforces the grammar of observers where OnError and OnCompleted are terminal messages.
|
1751
|
-
*/
|
1752
|
-
var AbstractObserver = Rx.internals.AbstractObserver = (function (_super) {
|
1753
|
-
inherits(AbstractObserver, _super);
|
1754
|
-
|
1755
|
-
/**
|
1756
|
-
* Creates a new observer in a non-stopped state.
|
1757
|
-
*
|
1758
|
-
* @constructor
|
1759
|
-
*/
|
1760
|
-
function AbstractObserver() {
|
1761
|
-
this.isStopped = false;
|
1762
|
-
_super.call(this);
|
1763
|
-
}
|
1764
|
-
|
1765
|
-
/**
|
1766
|
-
* Notifies the observer of a new element in the sequence.
|
1767
|
-
*
|
1768
|
-
* @memberOf AbstractObserver
|
1769
|
-
* @param {Any} value Next element in the sequence.
|
1770
|
-
*/
|
1771
|
-
AbstractObserver.prototype.onNext = function (value) {
|
1772
|
-
if (!this.isStopped) {
|
1773
|
-
this.next(value);
|
1774
|
-
}
|
1775
|
-
};
|
1776
|
-
|
1777
|
-
/**
|
1778
|
-
* Notifies the observer that an exception has occurred.
|
1779
|
-
*
|
1780
|
-
* @memberOf AbstractObserver
|
1781
|
-
* @param {Any} error The error that has occurred.
|
1782
|
-
*/
|
1783
|
-
AbstractObserver.prototype.onError = function (error) {
|
1784
|
-
if (!this.isStopped) {
|
1785
|
-
this.isStopped = true;
|
1786
|
-
this.error(error);
|
1787
|
-
}
|
1788
|
-
};
|
1789
1789
|
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1793
|
-
|
1794
|
-
|
1795
|
-
|
1796
|
-
this.completed();
|
1797
|
-
}
|
1798
|
-
};
|
1799
|
-
|
1800
|
-
/**
|
1801
|
-
* Disposes the observer, causing it to transition to the stopped state.
|
1802
|
-
*/
|
1803
|
-
AbstractObserver.prototype.dispose = function () {
|
1804
|
-
this.isStopped = true;
|
1805
|
-
};
|
1806
|
-
|
1807
|
-
AbstractObserver.prototype.fail = function (e) {
|
1808
|
-
if (!this.isStopped) {
|
1809
|
-
this.isStopped = true;
|
1810
|
-
this.error(e);
|
1811
|
-
return true;
|
1812
|
-
}
|
1790
|
+
AbstractObserver.prototype.fail = function (e) {
|
1791
|
+
if (!this.isStopped) {
|
1792
|
+
this.isStopped = true;
|
1793
|
+
this.error(e);
|
1794
|
+
return true;
|
1795
|
+
}
|
1813
1796
|
|
1814
|
-
|
1815
|
-
|
1797
|
+
return false;
|
1798
|
+
};
|
1816
1799
|
|
1817
|
-
|
1818
|
-
|
1800
|
+
return AbstractObserver;
|
1801
|
+
}(Observer));
|
1819
1802
|
|
1820
1803
|
/**
|
1821
1804
|
* Class to create an Observer instance from delegate-based implementations of the on* methods.
|
1822
1805
|
*/
|
1823
|
-
var AnonymousObserver = Rx.AnonymousObserver = (function (
|
1824
|
-
inherits(AnonymousObserver,
|
1806
|
+
var AnonymousObserver = Rx.AnonymousObserver = (function (__super__) {
|
1807
|
+
inherits(AnonymousObserver, __super__);
|
1825
1808
|
|
1826
1809
|
/**
|
1827
1810
|
* Creates an observer from the specified OnNext, OnError, and OnCompleted actions.
|
1828
1811
|
* @param {Any} onNext Observer's OnNext action implementation.
|
1829
1812
|
* @param {Any} onError Observer's OnError action implementation.
|
1830
|
-
* @param {Any} onCompleted Observer's OnCompleted action implementation.
|
1831
|
-
*/
|
1813
|
+
* @param {Any} onCompleted Observer's OnCompleted action implementation.
|
1814
|
+
*/
|
1832
1815
|
function AnonymousObserver(onNext, onError, onCompleted) {
|
1833
|
-
|
1816
|
+
__super__.call(this);
|
1834
1817
|
this._onNext = onNext;
|
1835
1818
|
this._onError = onError;
|
1836
1819
|
this._onCompleted = onCompleted;
|
@@ -1838,23 +1821,23 @@ if (!Array.prototype.forEach) {
|
|
1838
1821
|
|
1839
1822
|
/**
|
1840
1823
|
* Calls the onNext action.
|
1841
|
-
* @param {Any} value Next element in the sequence.
|
1842
|
-
*/
|
1824
|
+
* @param {Any} value Next element in the sequence.
|
1825
|
+
*/
|
1843
1826
|
AnonymousObserver.prototype.next = function (value) {
|
1844
1827
|
this._onNext(value);
|
1845
1828
|
};
|
1846
1829
|
|
1847
1830
|
/**
|
1848
1831
|
* Calls the onError action.
|
1849
|
-
* @param {Any} error The error that has occurred.
|
1850
|
-
*/
|
1851
|
-
AnonymousObserver.prototype.error = function (
|
1852
|
-
this._onError(
|
1832
|
+
* @param {Any} error The error that has occurred.
|
1833
|
+
*/
|
1834
|
+
AnonymousObserver.prototype.error = function (error) {
|
1835
|
+
this._onError(error);
|
1853
1836
|
};
|
1854
1837
|
|
1855
1838
|
/**
|
1856
1839
|
* Calls the onCompleted action.
|
1857
|
-
*/
|
1840
|
+
*/
|
1858
1841
|
AnonymousObserver.prototype.completed = function () {
|
1859
1842
|
this._onCompleted();
|
1860
1843
|
};
|
@@ -1877,24 +1860,45 @@ if (!Array.prototype.forEach) {
|
|
1877
1860
|
|
1878
1861
|
/**
|
1879
1862
|
* Subscribes an observer to the observable sequence.
|
1880
|
-
*
|
1881
|
-
* @example
|
1882
|
-
* 1 - source.subscribe();
|
1883
|
-
* 2 - source.subscribe(observer);
|
1884
|
-
* 3 - source.subscribe(function (x) { console.log(x); });
|
1885
|
-
* 4 - source.subscribe(function (x) { console.log(x); }, function (err) { console.log(err); });
|
1886
|
-
* 5 - source.subscribe(function (x) { console.log(x); }, function (err) { console.log(err); }, function () { console.log('done'); });
|
1887
1863
|
* @param {Mixed} [observerOrOnNext] The object that is to receive notifications or an action to invoke for each element in the observable sequence.
|
1888
1864
|
* @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence.
|
1889
1865
|
* @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence.
|
1890
|
-
* @returns {Diposable}
|
1866
|
+
* @returns {Diposable} A disposable handling the subscriptions and unsubscriptions.
|
1891
1867
|
*/
|
1892
1868
|
observableProto.subscribe = observableProto.forEach = function (observerOrOnNext, onError, onCompleted) {
|
1893
|
-
|
1869
|
+
return this._subscribe(typeof observerOrOnNext === 'object' ?
|
1894
1870
|
observerOrOnNext :
|
1895
|
-
observerCreate(observerOrOnNext, onError, onCompleted);
|
1871
|
+
observerCreate(observerOrOnNext, onError, onCompleted));
|
1872
|
+
};
|
1896
1873
|
|
1897
|
-
|
1874
|
+
/**
|
1875
|
+
* Subscribes to the next value in the sequence with an optional "this" argument.
|
1876
|
+
* @param {Function} onNext The function to invoke on each element in the observable sequence.
|
1877
|
+
* @param {Any} [thisArg] Object to use as this when executing callback.
|
1878
|
+
* @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.
|
1879
|
+
*/
|
1880
|
+
observableProto.subscribeOnNext = function (onNext, thisArg) {
|
1881
|
+
return this._subscribe(observerCreate(arguments.length === 2 ? function(x) { onNext.call(thisArg, x); } : onNext));
|
1882
|
+
};
|
1883
|
+
|
1884
|
+
/**
|
1885
|
+
* Subscribes to an exceptional condition in the sequence with an optional "this" argument.
|
1886
|
+
* @param {Function} onError The function to invoke upon exceptional termination of the observable sequence.
|
1887
|
+
* @param {Any} [thisArg] Object to use as this when executing callback.
|
1888
|
+
* @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.
|
1889
|
+
*/
|
1890
|
+
observableProto.subscribeOnError = function (onError, thisArg) {
|
1891
|
+
return this._subscribe(observerCreate(null, arguments.length === 2 ? function(e) { onError.call(thisArg, e); } : onError));
|
1892
|
+
};
|
1893
|
+
|
1894
|
+
/**
|
1895
|
+
* Subscribes to the next value in the sequence with an optional "this" argument.
|
1896
|
+
* @param {Function} onCompleted The function to invoke upon graceful termination of the observable sequence.
|
1897
|
+
* @param {Any} [thisArg] Object to use as this when executing callback.
|
1898
|
+
* @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.
|
1899
|
+
*/
|
1900
|
+
observableProto.subscribeOnCompleted = function (onCompleted, thisArg) {
|
1901
|
+
return this._subscribe(observerCreate(null, null, arguments.length === 2 ? function() { onCompleted.call(thisArg); } : onCompleted));
|
1898
1902
|
};
|
1899
1903
|
|
1900
1904
|
return Observable;
|
@@ -1971,7 +1975,7 @@ if (!Array.prototype.forEach) {
|
|
1971
1975
|
|
1972
1976
|
/**
|
1973
1977
|
* Creates a list from an observable sequence.
|
1974
|
-
* @returns An observable sequence containing a single element with a list containing all the elements of the source sequence.
|
1978
|
+
* @returns An observable sequence containing a single element with a list containing all the elements of the source sequence.
|
1975
1979
|
*/
|
1976
1980
|
observableProto.toArray = function () {
|
1977
1981
|
var self = this;
|
@@ -1989,12 +1993,12 @@ if (!Array.prototype.forEach) {
|
|
1989
1993
|
|
1990
1994
|
/**
|
1991
1995
|
* Creates an observable sequence from a specified subscribe method implementation.
|
1992
|
-
*
|
1996
|
+
*
|
1993
1997
|
* @example
|
1994
1998
|
* var res = Rx.Observable.create(function (observer) { return function () { } );
|
1995
|
-
* var res = Rx.Observable.create(function (observer) { return Rx.Disposable.empty; } );
|
1996
|
-
* var res = Rx.Observable.create(function (observer) { } );
|
1997
|
-
*
|
1999
|
+
* var res = Rx.Observable.create(function (observer) { return Rx.Disposable.empty; } );
|
2000
|
+
* var res = Rx.Observable.create(function (observer) { } );
|
2001
|
+
*
|
1998
2002
|
* @param {Function} subscribe Implementation of the resulting observable sequence's subscribe method, returning a function that will be wrapped in a Disposable.
|
1999
2003
|
* @returns {Observable} The observable sequence with the specified implementation for the Subscribe method.
|
2000
2004
|
*/
|
@@ -2004,9 +2008,9 @@ if (!Array.prototype.forEach) {
|
|
2004
2008
|
|
2005
2009
|
/**
|
2006
2010
|
* Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes.
|
2007
|
-
*
|
2011
|
+
*
|
2008
2012
|
* @example
|
2009
|
-
* var res = Rx.Observable.defer(function () { return Rx.Observable.fromArray([1,2,3]); });
|
2013
|
+
* var res = Rx.Observable.defer(function () { return Rx.Observable.fromArray([1,2,3]); });
|
2010
2014
|
* @param {Function} observableFactory Observable factory function to invoke for each observer that subscribes to the resulting sequence or Promise.
|
2011
2015
|
* @returns {Observable} An observable sequence whose observers trigger an invocation of the given observable factory function.
|
2012
2016
|
*/
|
@@ -2025,10 +2029,10 @@ if (!Array.prototype.forEach) {
|
|
2025
2029
|
|
2026
2030
|
/**
|
2027
2031
|
* Returns an empty observable sequence, using the specified scheduler to send out the single OnCompleted message.
|
2028
|
-
*
|
2032
|
+
*
|
2029
2033
|
* @example
|
2030
|
-
* var res = Rx.Observable.empty();
|
2031
|
-
* var res = Rx.Observable.empty(Rx.Scheduler.timeout);
|
2034
|
+
* var res = Rx.Observable.empty();
|
2035
|
+
* var res = Rx.Observable.empty(Rx.Scheduler.timeout);
|
2032
2036
|
* @param {Scheduler} [scheduler] Scheduler to send the termination call on.
|
2033
2037
|
* @returns {Observable} An observable sequence with no elements.
|
2034
2038
|
*/
|
@@ -2066,7 +2070,7 @@ if (!Array.prototype.forEach) {
|
|
2066
2070
|
var len = +o.length;
|
2067
2071
|
if (isNaN(len)) { return 0; }
|
2068
2072
|
if (len === 0 || !numberIsFinite(len)) { return len; }
|
2069
|
-
len = sign(len) * Math.floor(Math.abs(len));
|
2073
|
+
len = sign(len) * Math.floor(Math.abs(len));
|
2070
2074
|
if (len <= 0) { return 0; }
|
2071
2075
|
if (len > maxSafeInteger) { return maxSafeInteger; }
|
2072
2076
|
return len;
|
@@ -2118,7 +2122,7 @@ if (!Array.prototype.forEach) {
|
|
2118
2122
|
} catch (e) {
|
2119
2123
|
observer.onError(e);
|
2120
2124
|
return;
|
2121
|
-
}
|
2125
|
+
}
|
2122
2126
|
}
|
2123
2127
|
|
2124
2128
|
observer.onNext(result);
|
@@ -2130,9 +2134,10 @@ if (!Array.prototype.forEach) {
|
|
2130
2134
|
});
|
2131
2135
|
});
|
2132
2136
|
};
|
2137
|
+
|
2133
2138
|
/**
|
2134
2139
|
* Converts an array to an observable sequence, using an optional scheduler to enumerate the array.
|
2135
|
-
*
|
2140
|
+
*
|
2136
2141
|
* @example
|
2137
2142
|
* var res = Rx.Observable.fromArray([1,2,3]);
|
2138
2143
|
* var res = Rx.Observable.fromArray([1,2,3], Rx.Scheduler.timeout);
|
@@ -2177,7 +2182,7 @@ if (!Array.prototype.forEach) {
|
|
2177
2182
|
};
|
2178
2183
|
|
2179
2184
|
/**
|
2180
|
-
* This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.
|
2185
|
+
* This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.
|
2181
2186
|
* @example
|
2182
2187
|
* var res = Rx.Observable.of(1,2,3);
|
2183
2188
|
* @param {Scheduler} scheduler A scheduler to use for scheduling the arguments.
|
@@ -2191,7 +2196,7 @@ if (!Array.prototype.forEach) {
|
|
2191
2196
|
|
2192
2197
|
/**
|
2193
2198
|
* Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to send out observer messages.
|
2194
|
-
*
|
2199
|
+
*
|
2195
2200
|
* @example
|
2196
2201
|
* var res = Rx.Observable.range(0, 10);
|
2197
2202
|
* var res = Rx.Observable.range(0, 10, Rx.Scheduler.timeout);
|
@@ -2216,7 +2221,7 @@ if (!Array.prototype.forEach) {
|
|
2216
2221
|
|
2217
2222
|
/**
|
2218
2223
|
* Generates an observable sequence that repeats the given element the specified number of times, using the specified scheduler to send out observer messages.
|
2219
|
-
*
|
2224
|
+
*
|
2220
2225
|
* @example
|
2221
2226
|
* var res = Rx.Observable.repeat(42);
|
2222
2227
|
* var res = Rx.Observable.repeat(42, 4);
|
@@ -2235,7 +2240,7 @@ if (!Array.prototype.forEach) {
|
|
2235
2240
|
/**
|
2236
2241
|
* Returns an observable sequence that contains a single element, using the specified scheduler to send out observer messages.
|
2237
2242
|
* There is an alias called 'just', and 'returnValue' for browsers <IE9.
|
2238
|
-
*
|
2243
|
+
*
|
2239
2244
|
* @example
|
2240
2245
|
* var res = Rx.Observable.return(42);
|
2241
2246
|
* var res = Rx.Observable.return(42, Rx.Scheduler.timeout);
|
@@ -2287,7 +2292,7 @@ if (!Array.prototype.forEach) {
|
|
2287
2292
|
subscription.setDisposable(d);
|
2288
2293
|
d.setDisposable(result.subscribe(observer));
|
2289
2294
|
}, observer.onCompleted.bind(observer)));
|
2290
|
-
|
2295
|
+
|
2291
2296
|
return subscription;
|
2292
2297
|
});
|
2293
2298
|
}
|
@@ -2299,25 +2304,21 @@ if (!Array.prototype.forEach) {
|
|
2299
2304
|
* 2 - xs.catchException(function (ex) { return ys(ex); })
|
2300
2305
|
* @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.
|
2301
2306
|
* @returns {Observable} An observable sequence containing the first sequence's elements, followed by the elements of the handler sequence in case an exception occurred.
|
2302
|
-
*/
|
2303
|
-
observableProto['catch'] = observableProto.catchException = function (handlerOrSecond) {
|
2307
|
+
*/
|
2308
|
+
observableProto['catch'] = observableProto.catchError = observableProto.catchException = function (handlerOrSecond) {
|
2304
2309
|
return typeof handlerOrSecond === 'function' ?
|
2305
2310
|
observableCatchHandler(this, handlerOrSecond) :
|
2306
2311
|
observableCatch([this, handlerOrSecond]);
|
2307
2312
|
};
|
2308
2313
|
|
2309
|
-
|
2310
|
-
|
2311
|
-
|
2312
|
-
|
2313
|
-
|
2314
|
-
|
2315
|
-
|
2316
|
-
|
2317
|
-
var observableCatch = Observable.catchException = Observable['catch'] = function () {
|
2318
|
-
var items = argsOrArray(arguments, 0);
|
2319
|
-
return enumerableFor(items).catchException();
|
2320
|
-
};
|
2314
|
+
/**
|
2315
|
+
* Continues an observable sequence that is terminated by an exception with the next observable sequence.
|
2316
|
+
* @param {Array | Arguments} args Arguments or an array to use as the next sequence if an error occurs.
|
2317
|
+
* @returns {Observable} An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.
|
2318
|
+
*/
|
2319
|
+
var observableCatch = Observable.catchException = Observable.catchError = Observable['catch'] = function () {
|
2320
|
+
return enumerableOf(argsOrArray(arguments, 0)).catchException();
|
2321
|
+
};
|
2321
2322
|
|
2322
2323
|
/**
|
2323
2324
|
* 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.
|
@@ -2326,7 +2327,7 @@ if (!Array.prototype.forEach) {
|
|
2326
2327
|
* @example
|
2327
2328
|
* 1 - obs = observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
|
2328
2329
|
* 2 - obs = observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
|
2329
|
-
* @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
|
2330
|
+
* @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
|
2330
2331
|
*/
|
2331
2332
|
observableProto.combineLatest = function () {
|
2332
2333
|
var args = slice.call(arguments);
|
@@ -2340,15 +2341,15 @@ if (!Array.prototype.forEach) {
|
|
2340
2341
|
|
2341
2342
|
/**
|
2342
2343
|
* 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.
|
2343
|
-
*
|
2344
|
+
*
|
2344
2345
|
* @example
|
2345
2346
|
* 1 - obs = Rx.Observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
|
2346
|
-
* 2 - obs = Rx.Observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
|
2347
|
+
* 2 - obs = Rx.Observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
|
2347
2348
|
* @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
|
2348
2349
|
*/
|
2349
2350
|
var combineLatest = Observable.combineLatest = function () {
|
2350
2351
|
var args = slice.call(arguments), resultSelector = args.pop();
|
2351
|
-
|
2352
|
+
|
2352
2353
|
if (Array.isArray(args[0])) {
|
2353
2354
|
args = args[0];
|
2354
2355
|
}
|
@@ -2405,35 +2406,31 @@ if (!Array.prototype.forEach) {
|
|
2405
2406
|
|
2406
2407
|
/**
|
2407
2408
|
* Concatenates all the observable sequences. This takes in either an array or variable arguments to concatenate.
|
2408
|
-
*
|
2409
|
+
*
|
2409
2410
|
* @example
|
2410
2411
|
* 1 - concatenated = xs.concat(ys, zs);
|
2411
2412
|
* 2 - concatenated = xs.concat([ys, zs]);
|
2412
|
-
* @returns {Observable} An observable sequence that contains the elements of each given sequence, in sequential order.
|
2413
|
-
*/
|
2413
|
+
* @returns {Observable} An observable sequence that contains the elements of each given sequence, in sequential order.
|
2414
|
+
*/
|
2414
2415
|
observableProto.concat = function () {
|
2415
2416
|
var items = slice.call(arguments, 0);
|
2416
2417
|
items.unshift(this);
|
2417
2418
|
return observableConcat.apply(this, items);
|
2418
2419
|
};
|
2419
2420
|
|
2420
|
-
|
2421
|
-
|
2422
|
-
|
2423
|
-
|
2424
|
-
|
2425
|
-
|
2426
|
-
|
2427
|
-
|
2428
|
-
var observableConcat = Observable.concat = function () {
|
2429
|
-
var sources = argsOrArray(arguments, 0);
|
2430
|
-
return enumerableFor(sources).concat();
|
2431
|
-
};
|
2421
|
+
/**
|
2422
|
+
* Concatenates all the observable sequences.
|
2423
|
+
* @param {Array | Arguments} args Arguments or an array to concat to the observable sequence.
|
2424
|
+
* @returns {Observable} An observable sequence that contains the elements of each given sequence, in sequential order.
|
2425
|
+
*/
|
2426
|
+
var observableConcat = Observable.concat = function () {
|
2427
|
+
return enumerableOf(argsOrArray(arguments, 0)).concat();
|
2428
|
+
};
|
2432
2429
|
|
2433
2430
|
/**
|
2434
2431
|
* Concatenates an observable sequence of observable sequences.
|
2435
|
-
* @returns {Observable} An observable sequence that contains the elements of each observed inner sequence, in sequential order.
|
2436
|
-
*/
|
2432
|
+
* @returns {Observable} An observable sequence that contains the elements of each observed inner sequence, in sequential order.
|
2433
|
+
*/
|
2437
2434
|
observableProto.concatObservable = observableProto.concatAll =function () {
|
2438
2435
|
return this.merge(1);
|
2439
2436
|
};
|
@@ -2441,13 +2438,13 @@ if (!Array.prototype.forEach) {
|
|
2441
2438
|
/**
|
2442
2439
|
* Merges an observable sequence of observable sequences into an observable sequence, limiting the number of concurrent subscriptions to inner sequences.
|
2443
2440
|
* Or merges two observable sequences into a single observable sequence.
|
2444
|
-
*
|
2441
|
+
*
|
2445
2442
|
* @example
|
2446
2443
|
* 1 - merged = sources.merge(1);
|
2447
|
-
* 2 - merged = source.merge(otherSource);
|
2444
|
+
* 2 - merged = source.merge(otherSource);
|
2448
2445
|
* @param {Mixed} [maxConcurrentOrOther] Maximum number of inner observable sequences being subscribed to concurrently or the second observable sequence.
|
2449
|
-
* @returns {Observable} The observable sequence that merges the elements of the inner sequences.
|
2450
|
-
*/
|
2446
|
+
* @returns {Observable} The observable sequence that merges the elements of the inner sequences.
|
2447
|
+
*/
|
2451
2448
|
observableProto.merge = function (maxConcurrentOrOther) {
|
2452
2449
|
if (typeof maxConcurrentOrOther !== 'number') { return observableMerge(this, maxConcurrentOrOther); }
|
2453
2450
|
var sources = this;
|
@@ -2487,16 +2484,16 @@ if (!Array.prototype.forEach) {
|
|
2487
2484
|
};
|
2488
2485
|
|
2489
2486
|
/**
|
2490
|
-
* Merges all the observable sequences into a single observable sequence.
|
2487
|
+
* Merges all the observable sequences into a single observable sequence.
|
2491
2488
|
* The scheduler is optional and if not specified, the immediate scheduler is used.
|
2492
|
-
*
|
2489
|
+
*
|
2493
2490
|
* @example
|
2494
2491
|
* 1 - merged = Rx.Observable.merge(xs, ys, zs);
|
2495
2492
|
* 2 - merged = Rx.Observable.merge([xs, ys, zs]);
|
2496
2493
|
* 3 - merged = Rx.Observable.merge(scheduler, xs, ys, zs);
|
2497
|
-
* 4 - merged = Rx.Observable.merge(scheduler, [xs, ys, zs]);
|
2498
|
-
* @returns {Observable} The observable sequence that merges the elements of the observable sequences.
|
2499
|
-
*/
|
2494
|
+
* 4 - merged = Rx.Observable.merge(scheduler, [xs, ys, zs]);
|
2495
|
+
* @returns {Observable} The observable sequence that merges the elements of the observable sequences.
|
2496
|
+
*/
|
2500
2497
|
var observableMerge = Observable.merge = function () {
|
2501
2498
|
var scheduler, sources;
|
2502
2499
|
if (!arguments[0]) {
|
@@ -2513,13 +2510,13 @@ if (!Array.prototype.forEach) {
|
|
2513
2510
|
sources = sources[0];
|
2514
2511
|
}
|
2515
2512
|
return observableFromArray(sources, scheduler).mergeObservable();
|
2516
|
-
};
|
2513
|
+
};
|
2517
2514
|
|
2518
2515
|
/**
|
2519
2516
|
* Merges an observable sequence of observable sequences into an observable sequence.
|
2520
|
-
* @returns {Observable} The observable sequence that merges the elements of the inner sequences.
|
2521
|
-
*/
|
2522
|
-
observableProto.mergeObservable = observableProto.mergeAll =function () {
|
2517
|
+
* @returns {Observable} The observable sequence that merges the elements of the inner sequences.
|
2518
|
+
*/
|
2519
|
+
observableProto.mergeObservable = observableProto.mergeAll = function () {
|
2523
2520
|
var sources = this;
|
2524
2521
|
return new AnonymousObservable(function (observer) {
|
2525
2522
|
var group = new CompositeDisposable(),
|
@@ -2549,7 +2546,7 @@ if (!Array.prototype.forEach) {
|
|
2549
2546
|
/**
|
2550
2547
|
* Returns the values from the source observable sequence only after the other observable sequence produces a value.
|
2551
2548
|
* @param {Observable | Promise} other The observable sequence or Promise that triggers propagation of elements of the source sequence.
|
2552
|
-
* @returns {Observable} An observable sequence containing the elements of the source sequence starting from the point the other sequence triggered propagation.
|
2549
|
+
* @returns {Observable} An observable sequence containing the elements of the source sequence starting from the point the other sequence triggered propagation.
|
2553
2550
|
*/
|
2554
2551
|
observableProto.skipUntil = function (other) {
|
2555
2552
|
var source = this;
|
@@ -2578,7 +2575,7 @@ if (!Array.prototype.forEach) {
|
|
2578
2575
|
|
2579
2576
|
/**
|
2580
2577
|
* Transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
|
2581
|
-
* @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.
|
2578
|
+
* @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.
|
2582
2579
|
*/
|
2583
2580
|
observableProto['switch'] = observableProto.switchLatest = function () {
|
2584
2581
|
var sources = this;
|
@@ -2597,16 +2594,16 @@ if (!Array.prototype.forEach) {
|
|
2597
2594
|
isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
|
2598
2595
|
|
2599
2596
|
d.setDisposable(innerSource.subscribe(
|
2600
|
-
function (x) { latest === id && observer.onNext(x); },
|
2601
|
-
function (e) { latest === id && observer.onError(e); },
|
2597
|
+
function (x) { latest === id && observer.onNext(x); },
|
2598
|
+
function (e) { latest === id && observer.onError(e); },
|
2602
2599
|
function () {
|
2603
2600
|
if (latest === id) {
|
2604
2601
|
hasLatest = false;
|
2605
2602
|
isStopped && observer.onCompleted();
|
2606
2603
|
}
|
2607
2604
|
}));
|
2608
|
-
},
|
2609
|
-
observer.onError.bind(observer),
|
2605
|
+
},
|
2606
|
+
observer.onError.bind(observer),
|
2610
2607
|
function () {
|
2611
2608
|
isStopped = true;
|
2612
2609
|
!hasLatest && observer.onCompleted();
|
@@ -2618,7 +2615,7 @@ if (!Array.prototype.forEach) {
|
|
2618
2615
|
/**
|
2619
2616
|
* Returns the values from the source observable sequence until the other observable sequence produces a value.
|
2620
2617
|
* @param {Observable | Promise} other Observable sequence or Promise that terminates propagation of elements of the source sequence.
|
2621
|
-
* @returns {Observable} An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.
|
2618
|
+
* @returns {Observable} An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.
|
2622
2619
|
*/
|
2623
2620
|
observableProto.takeUntil = function (other) {
|
2624
2621
|
var source = this;
|
@@ -2650,7 +2647,7 @@ if (!Array.prototype.forEach) {
|
|
2650
2647
|
}
|
2651
2648
|
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
2652
2649
|
});
|
2653
|
-
}
|
2650
|
+
}
|
2654
2651
|
|
2655
2652
|
/**
|
2656
2653
|
* 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.
|
@@ -2658,9 +2655,9 @@ if (!Array.prototype.forEach) {
|
|
2658
2655
|
*
|
2659
2656
|
* @example
|
2660
2657
|
* 1 - res = obs1.zip(obs2, fn);
|
2661
|
-
* 1 - res = x1.zip([1,2,3], fn);
|
2662
|
-
* @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
|
2663
|
-
*/
|
2658
|
+
* 1 - res = x1.zip([1,2,3], fn);
|
2659
|
+
* @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
|
2660
|
+
*/
|
2664
2661
|
observableProto.zip = function () {
|
2665
2662
|
if (Array.isArray(arguments[0])) {
|
2666
2663
|
return zipArray.apply(this, arguments);
|
@@ -2671,7 +2668,7 @@ if (!Array.prototype.forEach) {
|
|
2671
2668
|
var n = sources.length,
|
2672
2669
|
queues = arrayInitialize(n, function () { return []; }),
|
2673
2670
|
isDone = arrayInitialize(n, function () { return false; });
|
2674
|
-
|
2671
|
+
|
2675
2672
|
function next(i) {
|
2676
2673
|
var res, queuedValues;
|
2677
2674
|
if (queues.every(function (x) { return x.length > 0; })) {
|
@@ -2713,74 +2710,72 @@ if (!Array.prototype.forEach) {
|
|
2713
2710
|
return new CompositeDisposable(subscriptions);
|
2714
2711
|
});
|
2715
2712
|
};
|
2716
|
-
/**
|
2717
|
-
* 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.
|
2718
|
-
* @param arguments Observable sources.
|
2719
|
-
* @param {Function} resultSelector Function to invoke for each series of elements at corresponding indexes in the sources.
|
2720
|
-
* @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
|
2721
|
-
*/
|
2722
|
-
Observable.zip = function () {
|
2723
|
-
var args = slice.call(arguments, 0),
|
2724
|
-
first = args.shift();
|
2725
|
-
return first.zip.apply(first, args);
|
2726
|
-
};
|
2727
2713
|
|
2728
|
-
|
2729
|
-
|
2730
|
-
|
2731
|
-
|
2732
|
-
|
2733
|
-
|
2734
|
-
|
2735
|
-
|
2736
|
-
|
2737
|
-
|
2738
|
-
isDone = arrayInitialize(n, function () { return false; });
|
2739
|
-
|
2740
|
-
function next(i) {
|
2741
|
-
if (queues.every(function (x) { return x.length > 0; })) {
|
2742
|
-
var res = queues.map(function (x) { return x.shift(); });
|
2743
|
-
observer.onNext(res);
|
2744
|
-
} else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) {
|
2745
|
-
observer.onCompleted();
|
2746
|
-
return;
|
2747
|
-
}
|
2748
|
-
};
|
2714
|
+
/**
|
2715
|
+
* 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.
|
2716
|
+
* @param arguments Observable sources.
|
2717
|
+
* @param {Function} resultSelector Function to invoke for each series of elements at corresponding indexes in the sources.
|
2718
|
+
* @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
|
2719
|
+
*/
|
2720
|
+
Observable.zip = function () {
|
2721
|
+
var args = slice.call(arguments, 0), first = args.shift();
|
2722
|
+
return first.zip.apply(first, args);
|
2723
|
+
};
|
2749
2724
|
|
2750
|
-
|
2751
|
-
|
2752
|
-
|
2753
|
-
|
2754
|
-
|
2755
|
-
|
2756
|
-
|
2725
|
+
/**
|
2726
|
+
* Merges the specified observable sequences into one observable sequence by emitting a list with the elements of the observable sequences at corresponding indexes.
|
2727
|
+
* @param arguments Observable sources.
|
2728
|
+
* @returns {Observable} An observable sequence containing lists of elements at corresponding indexes.
|
2729
|
+
*/
|
2730
|
+
Observable.zipArray = function () {
|
2731
|
+
var sources = argsOrArray(arguments, 0);
|
2732
|
+
return new AnonymousObservable(function (observer) {
|
2733
|
+
var n = sources.length,
|
2734
|
+
queues = arrayInitialize(n, function () { return []; }),
|
2735
|
+
isDone = arrayInitialize(n, function () { return false; });
|
2757
2736
|
|
2758
|
-
|
2759
|
-
|
2760
|
-
|
2761
|
-
|
2762
|
-
|
2763
|
-
|
2764
|
-
|
2765
|
-
|
2766
|
-
|
2767
|
-
}));
|
2768
|
-
})(idx);
|
2769
|
-
}
|
2737
|
+
function next(i) {
|
2738
|
+
if (queues.every(function (x) { return x.length > 0; })) {
|
2739
|
+
var res = queues.map(function (x) { return x.shift(); });
|
2740
|
+
observer.onNext(res);
|
2741
|
+
} else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) {
|
2742
|
+
observer.onCompleted();
|
2743
|
+
return;
|
2744
|
+
}
|
2745
|
+
};
|
2770
2746
|
|
2771
|
-
|
2772
|
-
|
2773
|
-
|
2774
|
-
|
2775
|
-
|
2776
|
-
|
2777
|
-
|
2778
|
-
|
2779
|
-
|
2747
|
+
function done(i) {
|
2748
|
+
isDone[i] = true;
|
2749
|
+
if (isDone.every(identity)) {
|
2750
|
+
observer.onCompleted();
|
2751
|
+
return;
|
2752
|
+
}
|
2753
|
+
}
|
2754
|
+
|
2755
|
+
var subscriptions = new Array(n);
|
2756
|
+
for (var idx = 0; idx < n; idx++) {
|
2757
|
+
(function (i) {
|
2758
|
+
subscriptions[i] = new SingleAssignmentDisposable();
|
2759
|
+
subscriptions[i].setDisposable(sources[i].subscribe(function (x) {
|
2760
|
+
queues[i].push(x);
|
2761
|
+
next(i);
|
2762
|
+
}, observer.onError.bind(observer), function () {
|
2763
|
+
done(i);
|
2764
|
+
}));
|
2765
|
+
})(idx);
|
2766
|
+
}
|
2767
|
+
|
2768
|
+
var compositeDisposable = new CompositeDisposable(subscriptions);
|
2769
|
+
compositeDisposable.add(disposableCreate(function () {
|
2770
|
+
for (var qIdx = 0, qLen = queues.length; qIdx < qLen; qIdx++) { queues[qIdx] = []; }
|
2771
|
+
}));
|
2772
|
+
return compositeDisposable;
|
2773
|
+
});
|
2774
|
+
};
|
2780
2775
|
|
2781
2776
|
/**
|
2782
2777
|
* Hides the identity of an observable sequence.
|
2783
|
-
* @returns {Observable} An observable sequence that hides the identity of the source sequence.
|
2778
|
+
* @returns {Observable} An observable sequence that hides the identity of the source sequence.
|
2784
2779
|
*/
|
2785
2780
|
observableProto.asObservable = function () {
|
2786
2781
|
return new AnonymousObservable(this.subscribe.bind(this));
|
@@ -2789,7 +2784,7 @@ if (!Array.prototype.forEach) {
|
|
2789
2784
|
/**
|
2790
2785
|
* Dematerializes the explicit notification values of an observable sequence as implicit notifications.
|
2791
2786
|
* @returns {Observable} An observable sequence exhibiting the behavior corresponding to the source sequence's notification values.
|
2792
|
-
*/
|
2787
|
+
*/
|
2793
2788
|
observableProto.dematerialize = function () {
|
2794
2789
|
var source = this;
|
2795
2790
|
return new AnonymousObservable(function (observer) {
|
@@ -2801,14 +2796,14 @@ if (!Array.prototype.forEach) {
|
|
2801
2796
|
|
2802
2797
|
/**
|
2803
2798
|
* Returns an observable sequence that contains only distinct contiguous elements according to the keySelector and the comparer.
|
2804
|
-
*
|
2799
|
+
*
|
2805
2800
|
* var obs = observable.distinctUntilChanged();
|
2806
2801
|
* var obs = observable.distinctUntilChanged(function (x) { return x.id; });
|
2807
2802
|
* var obs = observable.distinctUntilChanged(function (x) { return x.id; }, function (x, y) { return x === y; });
|
2808
2803
|
*
|
2809
2804
|
* @param {Function} [keySelector] A function to compute the comparison key for each element. If not provided, it projects the value.
|
2810
2805
|
* @param {Function} [comparer] Equality comparer for computed key values. If not provided, defaults to an equality comparer function.
|
2811
|
-
* @returns {Observable} An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence.
|
2806
|
+
* @returns {Observable} An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence.
|
2812
2807
|
*/
|
2813
2808
|
observableProto.distinctUntilChanged = function (keySelector, comparer) {
|
2814
2809
|
var source = this;
|
@@ -2844,16 +2839,10 @@ if (!Array.prototype.forEach) {
|
|
2844
2839
|
/**
|
2845
2840
|
* Invokes an action for each element in the observable sequence and invokes an action upon graceful or exceptional termination of the observable sequence.
|
2846
2841
|
* 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.
|
2847
|
-
*
|
2848
|
-
* @example
|
2849
|
-
* var res = observable.do(observer);
|
2850
|
-
* var res = observable.do(onNext);
|
2851
|
-
* var res = observable.do(onNext, onError);
|
2852
|
-
* var res = observable.do(onNext, onError, onCompleted);
|
2853
2842
|
* @param {Function | Observer} observerOrOnNext Action to invoke for each element in the observable sequence or an observer.
|
2854
2843
|
* @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.
|
2855
2844
|
* @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.
|
2856
|
-
* @returns {Observable} The source sequence with the side-effecting behavior applied.
|
2845
|
+
* @returns {Observable} The source sequence with the side-effecting behavior applied.
|
2857
2846
|
*/
|
2858
2847
|
observableProto['do'] = observableProto.doAction = observableProto.tap = function (observerOrOnNext, onError, onCompleted) {
|
2859
2848
|
var source = this, onNextFunc;
|
@@ -2873,39 +2862,68 @@ if (!Array.prototype.forEach) {
|
|
2873
2862
|
}
|
2874
2863
|
observer.onNext(x);
|
2875
2864
|
}, function (err) {
|
2876
|
-
if (
|
2877
|
-
observer.onError(err);
|
2878
|
-
} else {
|
2865
|
+
if (onError) {
|
2879
2866
|
try {
|
2880
2867
|
onError(err);
|
2881
2868
|
} catch (e) {
|
2882
2869
|
observer.onError(e);
|
2883
2870
|
}
|
2884
|
-
observer.onError(err);
|
2885
2871
|
}
|
2872
|
+
observer.onError(err);
|
2886
2873
|
}, function () {
|
2887
|
-
if (
|
2888
|
-
observer.onCompleted();
|
2889
|
-
} else {
|
2874
|
+
if (onCompleted) {
|
2890
2875
|
try {
|
2891
2876
|
onCompleted();
|
2892
2877
|
} catch (e) {
|
2893
2878
|
observer.onError(e);
|
2894
2879
|
}
|
2895
|
-
observer.onCompleted();
|
2896
2880
|
}
|
2881
|
+
observer.onCompleted();
|
2897
2882
|
});
|
2898
2883
|
});
|
2899
2884
|
};
|
2900
2885
|
|
2886
|
+
/**
|
2887
|
+
* Invokes an action for each element in the observable sequence.
|
2888
|
+
* 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.
|
2889
|
+
* @param {Function} onNext Action to invoke for each element in the observable sequence.
|
2890
|
+
* @param {Any} [thisArg] Object to use as this when executing callback.
|
2891
|
+
* @returns {Observable} The source sequence with the side-effecting behavior applied.
|
2892
|
+
*/
|
2893
|
+
observableProto.doOnNext = observableProto.tapOnNext = function (onNext, thisArg) {
|
2894
|
+
return this.tap(arguments.length === 2 ? function (x) { onNext.call(thisArg, x); } : onNext);
|
2895
|
+
};
|
2896
|
+
|
2897
|
+
/**
|
2898
|
+
* Invokes an action upon exceptional termination of the observable sequence.
|
2899
|
+
* 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.
|
2900
|
+
* @param {Function} onError Action to invoke upon exceptional termination of the observable sequence.
|
2901
|
+
* @param {Any} [thisArg] Object to use as this when executing callback.
|
2902
|
+
* @returns {Observable} The source sequence with the side-effecting behavior applied.
|
2903
|
+
*/
|
2904
|
+
observableProto.doOnError = observableProto.tapOnError = function (onError, thisArg) {
|
2905
|
+
return this.tap(noop, arguments.length === 2 ? function (e) { onError.call(thisArg, e); } : onError);
|
2906
|
+
};
|
2907
|
+
|
2908
|
+
/**
|
2909
|
+
* Invokes an action upon graceful termination of the observable sequence.
|
2910
|
+
* 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.
|
2911
|
+
* @param {Function} onCompleted Action to invoke upon graceful termination of the observable sequence.
|
2912
|
+
* @param {Any} [thisArg] Object to use as this when executing callback.
|
2913
|
+
* @returns {Observable} The source sequence with the side-effecting behavior applied.
|
2914
|
+
*/
|
2915
|
+
observableProto.doOnCompleted = observableProto.tapOnCompleted = function (onCompleted, thisArg) {
|
2916
|
+
return this.tap(noop, null, arguments.length === 2 ? function () { onCompleted.call(thisArg); } : onCompleted);
|
2917
|
+
};
|
2918
|
+
|
2901
2919
|
/**
|
2902
2920
|
* Invokes a specified action after the source observable sequence terminates gracefully or exceptionally.
|
2903
|
-
*
|
2921
|
+
*
|
2904
2922
|
* @example
|
2905
2923
|
* var res = observable.finallyAction(function () { console.log('sequence ended'; });
|
2906
2924
|
* @param {Function} finallyAction Action to invoke after the source observable sequence terminates.
|
2907
|
-
* @returns {Observable} Source sequence with the action-invoking termination behavior applied.
|
2908
|
-
*/
|
2925
|
+
* @returns {Observable} Source sequence with the action-invoking termination behavior applied.
|
2926
|
+
*/
|
2909
2927
|
observableProto['finally'] = observableProto.finallyAction = function (action) {
|
2910
2928
|
var source = this;
|
2911
2929
|
return new AnonymousObservable(function (observer) {
|
@@ -2919,8 +2937,8 @@ if (!Array.prototype.forEach) {
|
|
2919
2937
|
return disposableCreate(function () {
|
2920
2938
|
try {
|
2921
2939
|
subscription.dispose();
|
2922
|
-
} catch (e) {
|
2923
|
-
throw e;
|
2940
|
+
} catch (e) {
|
2941
|
+
throw e;
|
2924
2942
|
} finally {
|
2925
2943
|
action();
|
2926
2944
|
}
|
@@ -2930,7 +2948,7 @@ if (!Array.prototype.forEach) {
|
|
2930
2948
|
|
2931
2949
|
/**
|
2932
2950
|
* Ignores all elements in an observable sequence leaving only the termination messages.
|
2933
|
-
* @returns {Observable} An empty observable sequence that signals termination, successful or exceptional, of the source sequence.
|
2951
|
+
* @returns {Observable} An empty observable sequence that signals termination, successful or exceptional, of the source sequence.
|
2934
2952
|
*/
|
2935
2953
|
observableProto.ignoreElements = function () {
|
2936
2954
|
var source = this;
|
@@ -2942,7 +2960,7 @@ if (!Array.prototype.forEach) {
|
|
2942
2960
|
/**
|
2943
2961
|
* Materializes the implicit notifications of an observable sequence as explicit notification values.
|
2944
2962
|
* @returns {Observable} An observable sequence containing the materialized notification values from the source sequence.
|
2945
|
-
*/
|
2963
|
+
*/
|
2946
2964
|
observableProto.materialize = function () {
|
2947
2965
|
var source = this;
|
2948
2966
|
return new AnonymousObservable(function (observer) {
|
@@ -2960,12 +2978,12 @@ if (!Array.prototype.forEach) {
|
|
2960
2978
|
|
2961
2979
|
/**
|
2962
2980
|
* Repeats the observable sequence a specified number of times. If the repeat count is not specified, the sequence repeats indefinitely.
|
2963
|
-
*
|
2981
|
+
*
|
2964
2982
|
* @example
|
2965
2983
|
* var res = repeated = source.repeat();
|
2966
2984
|
* var res = repeated = source.repeat(42);
|
2967
2985
|
* @param {Number} [repeatCount] Number of times to repeat the sequence. If not provided, repeats the sequence indefinitely.
|
2968
|
-
* @returns {Observable} The observable sequence producing the elements of the given sequence repeatedly.
|
2986
|
+
* @returns {Observable} The observable sequence producing the elements of the given sequence repeatedly.
|
2969
2987
|
*/
|
2970
2988
|
observableProto.repeat = function (repeatCount) {
|
2971
2989
|
return enumerableRepeat(this, repeatCount).concat();
|
@@ -2974,12 +2992,12 @@ if (!Array.prototype.forEach) {
|
|
2974
2992
|
/**
|
2975
2993
|
* 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.
|
2976
2994
|
* Note if you encounter an error and want it to retry once, then you must use .retry(2);
|
2977
|
-
*
|
2995
|
+
*
|
2978
2996
|
* @example
|
2979
2997
|
* var res = retried = retry.repeat();
|
2980
2998
|
* var res = retried = retry.repeat(2);
|
2981
2999
|
* @param {Number} [retryCount] Number of times to retry the sequence. If not provided, retry the sequence indefinitely.
|
2982
|
-
* @returns {Observable} An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.
|
3000
|
+
* @returns {Observable} An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.
|
2983
3001
|
*/
|
2984
3002
|
observableProto.retry = function (retryCount) {
|
2985
3003
|
return enumerableRepeat(this, retryCount).catchException();
|
@@ -3000,7 +3018,7 @@ if (!Array.prototype.forEach) {
|
|
3000
3018
|
if (arguments.length === 2) {
|
3001
3019
|
hasSeed = true;
|
3002
3020
|
seed = arguments[0];
|
3003
|
-
accumulator = arguments[1];
|
3021
|
+
accumulator = arguments[1];
|
3004
3022
|
} else {
|
3005
3023
|
accumulator = arguments[0];
|
3006
3024
|
}
|
@@ -3015,7 +3033,7 @@ if (!Array.prototype.forEach) {
|
|
3015
3033
|
} else {
|
3016
3034
|
accumulation = hasSeed ? accumulator(seed, x) : x;
|
3017
3035
|
hasAccumulation = true;
|
3018
|
-
}
|
3036
|
+
}
|
3019
3037
|
} catch (e) {
|
3020
3038
|
observer.onError(e);
|
3021
3039
|
return;
|
@@ -3036,9 +3054,9 @@ if (!Array.prototype.forEach) {
|
|
3036
3054
|
* Bypasses a specified number of elements at the end of an observable sequence.
|
3037
3055
|
* @description
|
3038
3056
|
* This operator accumulates a queue with a length enough to store the first `count` elements. As more elements are
|
3039
|
-
* received, elements are taken from the front of the queue and produced on the result sequence. This causes elements to be delayed.
|
3057
|
+
* received, elements are taken from the front of the queue and produced on the result sequence. This causes elements to be delayed.
|
3040
3058
|
* @param count Number of elements to bypass at the end of the source sequence.
|
3041
|
-
* @returns {Observable} An observable sequence containing the source sequence elements except for the bypassed ones at the end.
|
3059
|
+
* @returns {Observable} An observable sequence containing the source sequence elements except for the bypassed ones at the end.
|
3042
3060
|
*/
|
3043
3061
|
observableProto.skipLast = function (count) {
|
3044
3062
|
var source = this;
|
@@ -3057,7 +3075,7 @@ if (!Array.prototype.forEach) {
|
|
3057
3075
|
* var res = source.startWith(1, 2, 3);
|
3058
3076
|
* var res = source.startWith(Rx.Scheduler.timeout, 1, 2, 3);
|
3059
3077
|
* @param {Arguments} args The specified values to prepend to the observable sequence
|
3060
|
-
* @returns {Observable} The source sequence prepended with the specified values.
|
3078
|
+
* @returns {Observable} The source sequence prepended with the specified values.
|
3061
3079
|
*/
|
3062
3080
|
observableProto.startWith = function () {
|
3063
3081
|
var values, scheduler, start = 0;
|
@@ -3068,7 +3086,7 @@ if (!Array.prototype.forEach) {
|
|
3068
3086
|
scheduler = immediateScheduler;
|
3069
3087
|
}
|
3070
3088
|
values = slice.call(arguments, start);
|
3071
|
-
return
|
3089
|
+
return enumerableOf([observableFromArray(values, scheduler), this]).concat();
|
3072
3090
|
};
|
3073
3091
|
|
3074
3092
|
/**
|
@@ -3078,7 +3096,7 @@ if (!Array.prototype.forEach) {
|
|
3078
3096
|
* the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.
|
3079
3097
|
* @param {Number} count Number of elements to take from the end of the source sequence.
|
3080
3098
|
* @returns {Observable} An observable sequence containing the specified number of elements from the end of the source sequence.
|
3081
|
-
*/
|
3099
|
+
*/
|
3082
3100
|
observableProto.takeLast = function (count) {
|
3083
3101
|
var source = this;
|
3084
3102
|
return new AnonymousObservable(function (observer) {
|
@@ -3103,21 +3121,21 @@ if (!Array.prototype.forEach) {
|
|
3103
3121
|
/**
|
3104
3122
|
* One of the Following:
|
3105
3123
|
* Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
|
3106
|
-
*
|
3124
|
+
*
|
3107
3125
|
* @example
|
3108
3126
|
* var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); });
|
3109
3127
|
* Or:
|
3110
3128
|
* 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.
|
3111
|
-
*
|
3129
|
+
*
|
3112
3130
|
* var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
|
3113
3131
|
* Or:
|
3114
3132
|
* Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
|
3115
|
-
*
|
3133
|
+
*
|
3116
3134
|
* var res = source.concatMap(Rx.Observable.fromArray([1,2,3]));
|
3117
|
-
* @param selector A transform function to apply to each element or an observable sequence to project each element from the
|
3135
|
+
* @param selector A transform function to apply to each element or an observable sequence to project each element from the
|
3118
3136
|
* source sequence onto which could be either an observable or Promise.
|
3119
3137
|
* @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
|
3120
|
-
* @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.
|
3138
|
+
* @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.
|
3121
3139
|
*/
|
3122
3140
|
observableProto.selectConcat = observableProto.concatMap = function (selector, resultSelector, thisArg) {
|
3123
3141
|
if (resultSelector) {
|
@@ -3128,36 +3146,36 @@ if (!Array.prototype.forEach) {
|
|
3128
3146
|
return result.map(function (y) {
|
3129
3147
|
return resultSelector(x, y, i);
|
3130
3148
|
});
|
3131
|
-
});
|
3132
|
-
}
|
3133
|
-
return typeof selector === 'function' ?
|
3134
|
-
concatMap(this, selector, thisArg) :
|
3135
|
-
concatMap(this, function () { return selector; });
|
3136
|
-
};
|
3137
|
-
|
3138
|
-
/**
|
3139
|
-
* Projects each element of an observable sequence into a new form by incorporating the element's index.
|
3140
|
-
* @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.
|
3141
|
-
* @param {Any} [thisArg] Object to use as this when executing callback.
|
3142
|
-
* @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source.
|
3143
|
-
*/
|
3144
|
-
observableProto.select = observableProto.map = function (selector, thisArg) {
|
3145
|
-
var parent = this;
|
3146
|
-
return new AnonymousObservable(function (observer) {
|
3147
|
-
var count = 0;
|
3148
|
-
return parent.subscribe(function (value) {
|
3149
|
-
var result;
|
3150
|
-
try {
|
3151
|
-
result = selector.call(thisArg, value, count++, parent);
|
3152
|
-
} catch (exception) {
|
3153
|
-
observer.onError(exception);
|
3154
|
-
return;
|
3155
|
-
}
|
3156
|
-
observer.onNext(result);
|
3157
|
-
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
3158
|
-
});
|
3149
|
+
});
|
3150
|
+
}
|
3151
|
+
return typeof selector === 'function' ?
|
3152
|
+
concatMap(this, selector, thisArg) :
|
3153
|
+
concatMap(this, function () { return selector; });
|
3159
3154
|
};
|
3160
3155
|
|
3156
|
+
/**
|
3157
|
+
* Projects each element of an observable sequence into a new form by incorporating the element's index.
|
3158
|
+
* @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.
|
3159
|
+
* @param {Any} [thisArg] Object to use as this when executing callback.
|
3160
|
+
* @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source.
|
3161
|
+
*/
|
3162
|
+
observableProto.select = observableProto.map = function (selector, thisArg) {
|
3163
|
+
var parent = this;
|
3164
|
+
return new AnonymousObservable(function (observer) {
|
3165
|
+
var count = 0;
|
3166
|
+
return parent.subscribe(function (value) {
|
3167
|
+
var result;
|
3168
|
+
try {
|
3169
|
+
result = selector.call(thisArg, value, count++, parent);
|
3170
|
+
} catch (e) {
|
3171
|
+
observer.onError(e);
|
3172
|
+
return;
|
3173
|
+
}
|
3174
|
+
observer.onNext(result);
|
3175
|
+
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
3176
|
+
});
|
3177
|
+
};
|
3178
|
+
|
3161
3179
|
/**
|
3162
3180
|
* Retrieves the value of a specified property from all elements in the Observable sequence.
|
3163
3181
|
* @param {String} prop The property to pluck.
|
@@ -3177,22 +3195,22 @@ if (!Array.prototype.forEach) {
|
|
3177
3195
|
/**
|
3178
3196
|
* One of the Following:
|
3179
3197
|
* Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
|
3180
|
-
*
|
3198
|
+
*
|
3181
3199
|
* @example
|
3182
3200
|
* var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); });
|
3183
3201
|
* Or:
|
3184
3202
|
* 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.
|
3185
|
-
*
|
3203
|
+
*
|
3186
3204
|
* var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
|
3187
3205
|
* Or:
|
3188
3206
|
* Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
|
3189
|
-
*
|
3207
|
+
*
|
3190
3208
|
* var res = source.selectMany(Rx.Observable.fromArray([1,2,3]));
|
3191
|
-
* @param selector A transform function to apply to each element or an observable sequence to project each element from the
|
3209
|
+
* @param selector A transform function to apply to each element or an observable sequence to project each element from the
|
3192
3210
|
* source sequence onto which could be either an observable or Promise.
|
3193
3211
|
* @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
|
3194
3212
|
* @param {Any} [thisArg] Object to use as this when executing callback.
|
3195
|
-
* @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.
|
3213
|
+
* @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.
|
3196
3214
|
*/
|
3197
3215
|
observableProto.selectMany = observableProto.flatMap = function (selector, resultSelector, thisArg) {
|
3198
3216
|
if (resultSelector) {
|
@@ -3211,11 +3229,11 @@ if (!Array.prototype.forEach) {
|
|
3211
3229
|
};
|
3212
3230
|
|
3213
3231
|
/**
|
3214
|
-
* Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then
|
3232
|
+
* Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then
|
3215
3233
|
* transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
|
3216
3234
|
* @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.
|
3217
3235
|
* @param {Any} [thisArg] Object to use as this when executing callback.
|
3218
|
-
* @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
|
3236
|
+
* @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
|
3219
3237
|
* and that at any point in time produces the elements of the most recent inner observable sequence that has been received.
|
3220
3238
|
*/
|
3221
3239
|
observableProto.selectSwitch = observableProto.flatMapLatest = observableProto.switchMap = function (selector, thisArg) {
|
@@ -3225,7 +3243,7 @@ if (!Array.prototype.forEach) {
|
|
3225
3243
|
/**
|
3226
3244
|
* Bypasses a specified number of elements in an observable sequence and then returns the remaining elements.
|
3227
3245
|
* @param {Number} count The number of elements to skip before returning the remaining elements.
|
3228
|
-
* @returns {Observable} An observable sequence that contains the elements that occur after the specified index in the input sequence.
|
3246
|
+
* @returns {Observable} An observable sequence that contains the elements that occur after the specified index in the input sequence.
|
3229
3247
|
*/
|
3230
3248
|
observableProto.skip = function (count) {
|
3231
3249
|
if (count < 0) { throw new Error(argumentOutOfRange); }
|
@@ -3245,12 +3263,12 @@ if (!Array.prototype.forEach) {
|
|
3245
3263
|
/**
|
3246
3264
|
* Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
|
3247
3265
|
* The element's index is used in the logic of the predicate function.
|
3248
|
-
*
|
3266
|
+
*
|
3249
3267
|
* var res = source.skipWhile(function (value) { return value < 10; });
|
3250
3268
|
* var res = source.skipWhile(function (value, index) { return value < 10 || index < 10; });
|
3251
3269
|
* @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.
|
3252
|
-
* @param {Any} [thisArg] Object to use as this when executing callback.
|
3253
|
-
* @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.
|
3270
|
+
* @param {Any} [thisArg] Object to use as this when executing callback.
|
3271
|
+
* @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.
|
3254
3272
|
*/
|
3255
3273
|
observableProto.skipWhile = function (predicate, thisArg) {
|
3256
3274
|
var source = this;
|
@@ -3272,12 +3290,12 @@ if (!Array.prototype.forEach) {
|
|
3272
3290
|
|
3273
3291
|
/**
|
3274
3292
|
* 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).
|
3275
|
-
*
|
3293
|
+
*
|
3276
3294
|
* var res = source.take(5);
|
3277
3295
|
* var res = source.take(0, Rx.Scheduler.timeout);
|
3278
3296
|
* @param {Number} count The number of elements to return.
|
3279
3297
|
* @param {Scheduler} [scheduler] Scheduler used to produce an OnCompleted message in case <paramref name="count count</paramref> is set to 0.
|
3280
|
-
* @returns {Observable} An observable sequence that contains the specified number of elements from the start of the input sequence.
|
3298
|
+
* @returns {Observable} An observable sequence that contains the specified number of elements from the start of the input sequence.
|
3281
3299
|
*/
|
3282
3300
|
observableProto.take = function (count, scheduler) {
|
3283
3301
|
if (count < 0) { throw new RangeError(argumentOutOfRange); }
|
@@ -3298,8 +3316,8 @@ if (!Array.prototype.forEach) {
|
|
3298
3316
|
* Returns elements from an observable sequence as long as a specified condition is true.
|
3299
3317
|
* The element's index is used in the logic of the predicate function.
|
3300
3318
|
* @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.
|
3301
|
-
* @param {Any} [thisArg] Object to use as this when executing callback.
|
3302
|
-
* @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.
|
3319
|
+
* @param {Any} [thisArg] Object to use as this when executing callback.
|
3320
|
+
* @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.
|
3303
3321
|
*/
|
3304
3322
|
observableProto.takeWhile = function (predicate, thisArg) {
|
3305
3323
|
var observable = this;
|
@@ -3323,38 +3341,36 @@ if (!Array.prototype.forEach) {
|
|
3323
3341
|
});
|
3324
3342
|
};
|
3325
3343
|
|
3326
|
-
|
3327
|
-
|
3328
|
-
|
3329
|
-
|
3330
|
-
|
3331
|
-
|
3332
|
-
|
3333
|
-
|
3334
|
-
|
3335
|
-
|
3336
|
-
|
3337
|
-
|
3338
|
-
|
3339
|
-
|
3340
|
-
|
3341
|
-
|
3342
|
-
|
3343
|
-
|
3344
|
-
|
3345
|
-
|
3346
|
-
|
3347
|
-
|
3348
|
-
|
3349
|
-
|
3350
|
-
|
3351
|
-
|
3352
|
-
});
|
3353
|
-
};
|
3344
|
+
/**
|
3345
|
+
* Filters the elements of an observable sequence based on a predicate by incorporating the element's index.
|
3346
|
+
*
|
3347
|
+
* @example
|
3348
|
+
* var res = source.where(function (value) { return value < 10; });
|
3349
|
+
* var res = source.where(function (value, index) { return value < 10 || index < 10; });
|
3350
|
+
* @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.
|
3351
|
+
* @param {Any} [thisArg] Object to use as this when executing callback.
|
3352
|
+
* @returns {Observable} An observable sequence that contains elements from the input sequence that satisfy the condition.
|
3353
|
+
*/
|
3354
|
+
observableProto.where = observableProto.filter = function (predicate, thisArg) {
|
3355
|
+
var parent = this;
|
3356
|
+
return new AnonymousObservable(function (observer) {
|
3357
|
+
var count = 0;
|
3358
|
+
return parent.subscribe(function (value) {
|
3359
|
+
var shouldRun;
|
3360
|
+
try {
|
3361
|
+
shouldRun = predicate.call(thisArg, value, count++, parent);
|
3362
|
+
} catch (e) {
|
3363
|
+
observer.onError(e);
|
3364
|
+
return;
|
3365
|
+
}
|
3366
|
+
shouldRun && observer.onNext(value);
|
3367
|
+
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
3368
|
+
});
|
3369
|
+
};
|
3354
3370
|
|
3355
3371
|
/**
|
3356
|
-
* Converts a callback function to an observable sequence.
|
3357
|
-
*
|
3372
|
+
* Converts a callback function to an observable sequence.
|
3373
|
+
*
|
3358
3374
|
* @param {Function} function Function with a callback as the last parameter to convert to an Observable sequence.
|
3359
3375
|
* @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
|
3360
3376
|
* @param {Function} [selector] A selector which takes the arguments from the callback to produce a single item to yield on next.
|
@@ -3367,7 +3383,7 @@ if (!Array.prototype.forEach) {
|
|
3367
3383
|
return new AnonymousObservable(function (observer) {
|
3368
3384
|
function handler(e) {
|
3369
3385
|
var results = e;
|
3370
|
-
|
3386
|
+
|
3371
3387
|
if (selector) {
|
3372
3388
|
try {
|
3373
3389
|
results = selector(arguments);
|
@@ -3378,13 +3394,13 @@ if (!Array.prototype.forEach) {
|
|
3378
3394
|
|
3379
3395
|
observer.onNext(results);
|
3380
3396
|
} else {
|
3381
|
-
if (results.length <= 1) {
|
3397
|
+
if (results.length <= 1) {
|
3382
3398
|
observer.onNext.apply(observer, results);
|
3383
3399
|
} else {
|
3384
3400
|
observer.onNext(results);
|
3385
3401
|
}
|
3386
3402
|
}
|
3387
|
-
|
3403
|
+
|
3388
3404
|
observer.onCompleted();
|
3389
3405
|
}
|
3390
3406
|
|
@@ -3398,7 +3414,7 @@ if (!Array.prototype.forEach) {
|
|
3398
3414
|
* Converts a Node.js callback style function to an observable sequence. This must be in function (err, ...) format.
|
3399
3415
|
* @param {Function} func The function to call
|
3400
3416
|
* @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
|
3401
|
-
* @param {Function} [selector] A selector which takes the arguments from the callback minus the error to produce a single item to yield on next.
|
3417
|
+
* @param {Function} [selector] A selector which takes the arguments from the callback minus the error to produce a single item to yield on next.
|
3402
3418
|
* @returns {Function} An async function which when applied, returns an observable sequence with the callback arguments as an array.
|
3403
3419
|
*/
|
3404
3420
|
Observable.fromNodeCallback = function (func, context, selector) {
|
@@ -3413,7 +3429,7 @@ if (!Array.prototype.forEach) {
|
|
3413
3429
|
}
|
3414
3430
|
|
3415
3431
|
var results = slice.call(arguments, 1);
|
3416
|
-
|
3432
|
+
|
3417
3433
|
if (selector) {
|
3418
3434
|
try {
|
3419
3435
|
results = selector(results);
|
@@ -3423,7 +3439,7 @@ if (!Array.prototype.forEach) {
|
|
3423
3439
|
}
|
3424
3440
|
observer.onNext(results);
|
3425
3441
|
} else {
|
3426
|
-
if (results.length <= 1) {
|
3442
|
+
if (results.length <= 1) {
|
3427
3443
|
observer.onNext.apply(observer, results);
|
3428
3444
|
} else {
|
3429
3445
|
observer.onNext(results);
|
@@ -3458,7 +3474,7 @@ if (!Array.prototype.forEach) {
|
|
3458
3474
|
|
3459
3475
|
event || (event = root.event);
|
3460
3476
|
if (!event.target) {
|
3461
|
-
event.target = event.target || event.srcElement;
|
3477
|
+
event.target = event.target || event.srcElement;
|
3462
3478
|
|
3463
3479
|
if (event.type == 'mouseover') {
|
3464
3480
|
event.relatedTarget = event.fromElement;
|
@@ -3479,14 +3495,14 @@ if (!Array.prototype.forEach) {
|
|
3479
3495
|
c = 0;
|
3480
3496
|
event.keyCode = 13;
|
3481
3497
|
} else if (c == 13 || c == 27) {
|
3482
|
-
c = 0;
|
3498
|
+
c = 0;
|
3483
3499
|
} else if (c == 3) {
|
3484
|
-
c = 99;
|
3500
|
+
c = 99;
|
3485
3501
|
}
|
3486
3502
|
event.charCode = c;
|
3487
3503
|
event.keyChar = event.charCode ? String.fromCharCode(event.charCode) : '';
|
3488
3504
|
break;
|
3489
|
-
}
|
3505
|
+
}
|
3490
3506
|
}
|
3491
3507
|
|
3492
3508
|
return event;
|
@@ -3499,7 +3515,7 @@ if (!Array.prototype.forEach) {
|
|
3499
3515
|
return disposableCreate(function () {
|
3500
3516
|
element.removeEventListener(name, handler, false);
|
3501
3517
|
});
|
3502
|
-
}
|
3518
|
+
}
|
3503
3519
|
if (element.attachEvent) {
|
3504
3520
|
// IE Specific
|
3505
3521
|
var innerHandler = function (event) {
|
@@ -3508,9 +3524,9 @@ if (!Array.prototype.forEach) {
|
|
3508
3524
|
element.attachEvent('on' + name, innerHandler);
|
3509
3525
|
return disposableCreate(function () {
|
3510
3526
|
element.detachEvent('on' + name, innerHandler);
|
3511
|
-
});
|
3527
|
+
});
|
3512
3528
|
}
|
3513
|
-
// Level 1 DOM Events
|
3529
|
+
// Level 1 DOM Events
|
3514
3530
|
element['on' + name] = handler;
|
3515
3531
|
return disposableCreate(function () {
|
3516
3532
|
element['on' + name] = null;
|
@@ -3533,7 +3549,7 @@ if (!Array.prototype.forEach) {
|
|
3533
3549
|
}
|
3534
3550
|
|
3535
3551
|
/**
|
3536
|
-
* Configuration option to determine whether to use native events only
|
3552
|
+
* Configuration option to determine whether to use native events only
|
3537
3553
|
*/
|
3538
3554
|
Rx.config.useNativeEvents = false;
|
3539
3555
|
|
@@ -3545,7 +3561,7 @@ if (!Array.prototype.forEach) {
|
|
3545
3561
|
|
3546
3562
|
// Check for ember
|
3547
3563
|
var ember = !!root.Ember && typeof root.Ember.addListener === 'function';
|
3548
|
-
|
3564
|
+
|
3549
3565
|
// Check for Backbone.Marionette. Note if using AMD add Marionette as a dependency of rxjs
|
3550
3566
|
// for proper loading order!
|
3551
3567
|
var marionette = !!root.Backbone && !!root.Backbone.Marionette;
|
@@ -3555,10 +3571,10 @@ if (!Array.prototype.forEach) {
|
|
3555
3571
|
*
|
3556
3572
|
* @example
|
3557
3573
|
* var source = Rx.Observable.fromEvent(element, 'mouseup');
|
3558
|
-
*
|
3574
|
+
*
|
3559
3575
|
* @param {Object} element The DOMElement or NodeList to attach a listener.
|
3560
3576
|
* @param {String} eventName The event name to attach the observable sequence.
|
3561
|
-
* @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.
|
3577
|
+
* @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.
|
3562
3578
|
* @returns {Observable} An observable sequence of events from the specified element and the specified event.
|
3563
3579
|
*/
|
3564
3580
|
Observable.fromEvent = function (element, eventName, selector) {
|
@@ -3568,7 +3584,7 @@ if (!Array.prototype.forEach) {
|
|
3568
3584
|
function (h) { element.addListener(eventName, h); },
|
3569
3585
|
function (h) { element.removeListener(eventName, h); },
|
3570
3586
|
selector);
|
3571
|
-
}
|
3587
|
+
}
|
3572
3588
|
|
3573
3589
|
// Use only if non-native events are allowed
|
3574
3590
|
if (!Rx.config.useNativeEvents) {
|
@@ -3583,7 +3599,7 @@ if (!Array.prototype.forEach) {
|
|
3583
3599
|
function (h) { Ember.addListener(element, eventName, h); },
|
3584
3600
|
function (h) { Ember.removeListener(element, eventName, h); },
|
3585
3601
|
selector);
|
3586
|
-
}
|
3602
|
+
}
|
3587
3603
|
if (jq) {
|
3588
3604
|
var $elem = jq(element);
|
3589
3605
|
return fromEventPattern(
|
@@ -3594,9 +3610,9 @@ if (!Array.prototype.forEach) {
|
|
3594
3610
|
}
|
3595
3611
|
return new AnonymousObservable(function (observer) {
|
3596
3612
|
return createEventListener(
|
3597
|
-
element,
|
3598
|
-
eventName,
|
3599
|
-
function handler (e) {
|
3613
|
+
element,
|
3614
|
+
eventName,
|
3615
|
+
function handler (e) {
|
3600
3616
|
var results = e;
|
3601
3617
|
|
3602
3618
|
if (selector) {
|
@@ -3608,7 +3624,7 @@ if (!Array.prototype.forEach) {
|
|
3608
3624
|
}
|
3609
3625
|
}
|
3610
3626
|
|
3611
|
-
observer.onNext(results);
|
3627
|
+
observer.onNext(results);
|
3612
3628
|
});
|
3613
3629
|
}).publish().refCount();
|
3614
3630
|
};
|
@@ -3665,11 +3681,12 @@ if (!Array.prototype.forEach) {
|
|
3665
3681
|
return subject;
|
3666
3682
|
});
|
3667
3683
|
};
|
3684
|
+
|
3668
3685
|
/*
|
3669
3686
|
* Converts an existing observable sequence to an ES6 Compatible Promise
|
3670
3687
|
* @example
|
3671
3688
|
* var promise = Rx.Observable.return(42).toPromise(RSVP.Promise);
|
3672
|
-
*
|
3689
|
+
*
|
3673
3690
|
* // With config
|
3674
3691
|
* Rx.config.Promise = RSVP.Promise;
|
3675
3692
|
* var promise = Rx.Observable.return(42).toPromise();
|
@@ -3691,6 +3708,7 @@ if (!Array.prototype.forEach) {
|
|
3691
3708
|
});
|
3692
3709
|
});
|
3693
3710
|
};
|
3711
|
+
|
3694
3712
|
/**
|
3695
3713
|
* Invokes the asynchronous function, surfacing the result through an observable sequence.
|
3696
3714
|
* @param {Function} functionAsync Asynchronous function which returns a Promise to run.
|
@@ -3710,16 +3728,16 @@ if (!Array.prototype.forEach) {
|
|
3710
3728
|
* Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function. Each
|
3711
3729
|
* subscription to the resulting sequence causes a separate multicast invocation, exposing the sequence resulting from the selector function's
|
3712
3730
|
* invocation. For specializations with fixed subject types, see Publish, PublishLast, and Replay.
|
3713
|
-
*
|
3731
|
+
*
|
3714
3732
|
* @example
|
3715
3733
|
* 1 - res = source.multicast(observable);
|
3716
3734
|
* 2 - res = source.multicast(function () { return new Subject(); }, function (x) { return x; });
|
3717
|
-
*
|
3718
|
-
* @param {Function|Subject} subjectOrSubjectSelector
|
3735
|
+
*
|
3736
|
+
* @param {Function|Subject} subjectOrSubjectSelector
|
3719
3737
|
* Factory function to create an intermediate subject through which the source sequence's elements will be multicast to the selector function.
|
3720
3738
|
* Or:
|
3721
3739
|
* Subject to push source elements into.
|
3722
|
-
*
|
3740
|
+
*
|
3723
3741
|
* @param {Function} [selector] Optional selector function which can use the multicasted source sequence subject to the policies enforced by the created subject. Specified only if <paramref name="subjectOrSubjectSelector" is a factory function.
|
3724
3742
|
* @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
|
3725
3743
|
*/
|
@@ -3736,11 +3754,11 @@ if (!Array.prototype.forEach) {
|
|
3736
3754
|
/**
|
3737
3755
|
* Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence.
|
3738
3756
|
* This operator is a specialization of Multicast using a regular Subject.
|
3739
|
-
*
|
3757
|
+
*
|
3740
3758
|
* @example
|
3741
3759
|
* var resres = source.publish();
|
3742
3760
|
* var res = source.publish(function (x) { return x; });
|
3743
|
-
*
|
3761
|
+
*
|
3744
3762
|
* @param {Function} [selector] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all notifications of the source from the time of the subscription on.
|
3745
3763
|
* @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
|
3746
3764
|
*/
|
@@ -3753,10 +3771,10 @@ if (!Array.prototype.forEach) {
|
|
3753
3771
|
/**
|
3754
3772
|
* Returns an observable sequence that shares a single subscription to the underlying sequence.
|
3755
3773
|
* This operator is a specialization of publish which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed.
|
3756
|
-
*
|
3774
|
+
*
|
3757
3775
|
* @example
|
3758
3776
|
* var res = source.share();
|
3759
|
-
*
|
3777
|
+
*
|
3760
3778
|
* @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence.
|
3761
3779
|
*/
|
3762
3780
|
observableProto.share = function () {
|
@@ -3766,11 +3784,11 @@ if (!Array.prototype.forEach) {
|
|
3766
3784
|
/**
|
3767
3785
|
* Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence containing only the last notification.
|
3768
3786
|
* This operator is a specialization of Multicast using a AsyncSubject.
|
3769
|
-
*
|
3787
|
+
*
|
3770
3788
|
* @example
|
3771
3789
|
* var res = source.publishLast();
|
3772
3790
|
* var res = source.publishLast(function (x) { return x; });
|
3773
|
-
*
|
3791
|
+
*
|
3774
3792
|
* @param selector [Optional] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will only receive the last notification of the source.
|
3775
3793
|
* @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
|
3776
3794
|
*/
|
@@ -3783,11 +3801,11 @@ if (!Array.prototype.forEach) {
|
|
3783
3801
|
/**
|
3784
3802
|
* Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence and starts with initialValue.
|
3785
3803
|
* This operator is a specialization of Multicast using a BehaviorSubject.
|
3786
|
-
*
|
3804
|
+
*
|
3787
3805
|
* @example
|
3788
3806
|
* var res = source.publishValue(42);
|
3789
3807
|
* var res = source.publishValue(function (x) { return x.select(function (y) { return y * y; }) }, 42);
|
3790
|
-
*
|
3808
|
+
*
|
3791
3809
|
* @param {Function} [selector] Optional selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive immediately receive the initial value, followed by all notifications of the source from the time of the subscription on.
|
3792
3810
|
* @param {Mixed} initialValue Initial value received by observers upon subscription.
|
3793
3811
|
* @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
|
@@ -3803,10 +3821,10 @@ if (!Array.prototype.forEach) {
|
|
3803
3821
|
/**
|
3804
3822
|
* Returns an observable sequence that shares a single subscription to the underlying sequence and starts with an initialValue.
|
3805
3823
|
* This operator is a specialization of publishValue which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed.
|
3806
|
-
*
|
3824
|
+
*
|
3807
3825
|
* @example
|
3808
3826
|
* var res = source.shareValue(42);
|
3809
|
-
*
|
3827
|
+
*
|
3810
3828
|
* @param {Mixed} initialValue Initial value received by observers upon subscription.
|
3811
3829
|
* @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence.
|
3812
3830
|
*/
|
@@ -3817,13 +3835,13 @@ if (!Array.prototype.forEach) {
|
|
3817
3835
|
/**
|
3818
3836
|
* Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence replaying notifications subject to a maximum time length for the replay buffer.
|
3819
3837
|
* This operator is a specialization of Multicast using a ReplaySubject.
|
3820
|
-
*
|
3838
|
+
*
|
3821
3839
|
* @example
|
3822
3840
|
* var res = source.replay(null, 3);
|
3823
3841
|
* var res = source.replay(null, 3, 500);
|
3824
3842
|
* var res = source.replay(null, 3, 500, scheduler);
|
3825
3843
|
* var res = source.replay(function (x) { return x.take(6).repeat(); }, 3, 500, scheduler);
|
3826
|
-
*
|
3844
|
+
*
|
3827
3845
|
* @param selector [Optional] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all the notifications of the source subject to the specified replay buffer trimming policy.
|
3828
3846
|
* @param bufferSize [Optional] Maximum element count of the replay buffer.
|
3829
3847
|
* @param window [Optional] Maximum time length of the replay buffer.
|
@@ -3839,12 +3857,12 @@ if (!Array.prototype.forEach) {
|
|
3839
3857
|
/**
|
3840
3858
|
* Returns an observable sequence that shares a single subscription to the underlying sequence replaying notifications subject to a maximum time length for the replay buffer.
|
3841
3859
|
* This operator is a specialization of replay which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed.
|
3842
|
-
*
|
3860
|
+
*
|
3843
3861
|
* @example
|
3844
3862
|
* var res = source.shareReplay(3);
|
3845
3863
|
* var res = source.shareReplay(3, 500);
|
3846
3864
|
* var res = source.shareReplay(3, 500, scheduler);
|
3847
|
-
*
|
3865
|
+
*
|
3848
3866
|
|
3849
3867
|
* @param bufferSize [Optional] Maximum element count of the replay buffer.
|
3850
3868
|
* @param window [Optional] Maximum time length of the replay buffer.
|
@@ -3855,42 +3873,43 @@ if (!Array.prototype.forEach) {
|
|
3855
3873
|
return this.replay(null, bufferSize, window, scheduler).refCount();
|
3856
3874
|
};
|
3857
3875
|
|
3858
|
-
var ConnectableObservable = Rx.ConnectableObservable = (function (__super__) {
|
3859
|
-
inherits(ConnectableObservable, __super__);
|
3860
|
-
|
3861
|
-
function ConnectableObservable(source, subject) {
|
3862
|
-
var hasSubscription = false,
|
3863
|
-
subscription,
|
3864
|
-
sourceObservable = source.asObservable();
|
3865
|
-
|
3866
|
-
this.connect = function () {
|
3867
|
-
if (!hasSubscription) {
|
3868
|
-
hasSubscription = true;
|
3869
|
-
subscription = new CompositeDisposable(sourceObservable.subscribe(subject), disposableCreate(function () {
|
3870
|
-
hasSubscription = false;
|
3871
|
-
}));
|
3872
|
-
}
|
3873
|
-
return subscription;
|
3874
|
-
};
|
3875
|
-
|
3876
|
-
__super__.call(this, subject.subscribe.bind(subject));
|
3877
|
-
}
|
3878
|
-
|
3879
|
-
ConnectableObservable.prototype.refCount = function () {
|
3880
|
-
var connectableSubscription, count = 0, source = this;
|
3881
|
-
return new AnonymousObservable(function (observer) {
|
3882
|
-
var shouldConnect = ++count === 1,
|
3883
|
-
subscription = source.subscribe(observer);
|
3884
|
-
shouldConnect && (connectableSubscription = source.connect());
|
3885
|
-
return function () {
|
3886
|
-
subscription.dispose();
|
3887
|
-
--count === 0 && connectableSubscription.dispose();
|
3888
|
-
};
|
3889
|
-
});
|
3890
|
-
};
|
3891
|
-
|
3892
|
-
return ConnectableObservable;
|
3876
|
+
var ConnectableObservable = Rx.ConnectableObservable = (function (__super__) {
|
3877
|
+
inherits(ConnectableObservable, __super__);
|
3878
|
+
|
3879
|
+
function ConnectableObservable(source, subject) {
|
3880
|
+
var hasSubscription = false,
|
3881
|
+
subscription,
|
3882
|
+
sourceObservable = source.asObservable();
|
3883
|
+
|
3884
|
+
this.connect = function () {
|
3885
|
+
if (!hasSubscription) {
|
3886
|
+
hasSubscription = true;
|
3887
|
+
subscription = new CompositeDisposable(sourceObservable.subscribe(subject), disposableCreate(function () {
|
3888
|
+
hasSubscription = false;
|
3889
|
+
}));
|
3890
|
+
}
|
3891
|
+
return subscription;
|
3892
|
+
};
|
3893
|
+
|
3894
|
+
__super__.call(this, subject.subscribe.bind(subject));
|
3895
|
+
}
|
3896
|
+
|
3897
|
+
ConnectableObservable.prototype.refCount = function () {
|
3898
|
+
var connectableSubscription, count = 0, source = this;
|
3899
|
+
return new AnonymousObservable(function (observer) {
|
3900
|
+
var shouldConnect = ++count === 1,
|
3901
|
+
subscription = source.subscribe(observer);
|
3902
|
+
shouldConnect && (connectableSubscription = source.connect());
|
3903
|
+
return function () {
|
3904
|
+
subscription.dispose();
|
3905
|
+
--count === 0 && connectableSubscription.dispose();
|
3906
|
+
};
|
3907
|
+
});
|
3908
|
+
};
|
3909
|
+
|
3910
|
+
return ConnectableObservable;
|
3893
3911
|
}(Observable));
|
3912
|
+
|
3894
3913
|
function observableTimerDate(dueTime, scheduler) {
|
3895
3914
|
return new AnonymousObservable(function (observer) {
|
3896
3915
|
return scheduler.scheduleWithAbsolute(dueTime, function () {
|
@@ -3939,11 +3958,11 @@ if (!Array.prototype.forEach) {
|
|
3939
3958
|
|
3940
3959
|
/**
|
3941
3960
|
* Returns an observable sequence that produces a value after each period.
|
3942
|
-
*
|
3961
|
+
*
|
3943
3962
|
* @example
|
3944
3963
|
* 1 - res = Rx.Observable.interval(1000);
|
3945
3964
|
* 2 - res = Rx.Observable.interval(1000, Rx.Scheduler.timeout);
|
3946
|
-
*
|
3965
|
+
*
|
3947
3966
|
* @param {Number} period Period for producing the values in the resulting sequence (specified as an integer denoting milliseconds).
|
3948
3967
|
* @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, Rx.Scheduler.timeout is used.
|
3949
3968
|
* @returns {Observable} An observable sequence that produces a value after each period.
|
@@ -4051,11 +4070,11 @@ if (!Array.prototype.forEach) {
|
|
4051
4070
|
|
4052
4071
|
/**
|
4053
4072
|
* Time shifts the observable sequence by dueTime. The relative time intervals between the values are preserved.
|
4054
|
-
*
|
4073
|
+
*
|
4055
4074
|
* @example
|
4056
4075
|
* 1 - res = Rx.Observable.delay(new Date());
|
4057
4076
|
* 2 - res = Rx.Observable.delay(new Date(), Rx.Scheduler.timeout);
|
4058
|
-
*
|
4077
|
+
*
|
4059
4078
|
* 3 - res = Rx.Observable.delay(5000);
|
4060
4079
|
* 4 - res = Rx.Observable.delay(5000, 1000, Rx.Scheduler.timeout);
|
4061
4080
|
* @memberOf Observable#
|
@@ -4072,11 +4091,11 @@ if (!Array.prototype.forEach) {
|
|
4072
4091
|
|
4073
4092
|
/**
|
4074
4093
|
* Ignores values from an observable sequence which are followed by another value before dueTime.
|
4075
|
-
*
|
4094
|
+
*
|
4076
4095
|
* @example
|
4077
4096
|
* 1 - res = source.throttle(5000); // 5 seconds
|
4078
|
-
* 2 - res = source.throttle(5000, scheduler);
|
4079
|
-
*
|
4097
|
+
* 2 - res = source.throttle(5000, scheduler);
|
4098
|
+
*
|
4080
4099
|
* @param {Number} dueTime Duration of the throttle period for each value (specified as an integer denoting milliseconds).
|
4081
4100
|
* @param {Scheduler} [scheduler] Scheduler to run the throttle timers on. If not specified, the timeout scheduler is used.
|
4082
4101
|
* @returns {Observable} The throttled sequence.
|
@@ -4095,16 +4114,16 @@ if (!Array.prototype.forEach) {
|
|
4095
4114
|
d = new SingleAssignmentDisposable();
|
4096
4115
|
cancelable.setDisposable(d);
|
4097
4116
|
d.setDisposable(scheduler.scheduleWithRelative(dueTime, function () {
|
4098
|
-
|
4117
|
+
hasvalue && id === currentId && observer.onNext(value);
|
4099
4118
|
hasvalue = false;
|
4100
4119
|
}));
|
4101
|
-
},
|
4120
|
+
},
|
4102
4121
|
function (e) {
|
4103
4122
|
cancelable.dispose();
|
4104
4123
|
observer.onError(e);
|
4105
4124
|
hasvalue = false;
|
4106
4125
|
id++;
|
4107
|
-
},
|
4126
|
+
},
|
4108
4127
|
function () {
|
4109
4128
|
cancelable.dispose();
|
4110
4129
|
hasvalue && observer.onNext(value);
|
@@ -4118,11 +4137,11 @@ if (!Array.prototype.forEach) {
|
|
4118
4137
|
|
4119
4138
|
/**
|
4120
4139
|
* Records the timestamp for each value in an observable sequence.
|
4121
|
-
*
|
4140
|
+
*
|
4122
4141
|
* @example
|
4123
4142
|
* 1 - res = source.timestamp(); // produces { value: x, timestamp: ts }
|
4124
4143
|
* 2 - res = source.timestamp(Rx.Scheduler.timeout);
|
4125
|
-
*
|
4144
|
+
*
|
4126
4145
|
* @param {Scheduler} [scheduler] Scheduler used to compute timestamps. If not specified, the timeout scheduler is used.
|
4127
4146
|
* @returns {Observable} An observable sequence with timestamp information on values.
|
4128
4147
|
*/
|
@@ -4134,7 +4153,7 @@ if (!Array.prototype.forEach) {
|
|
4134
4153
|
};
|
4135
4154
|
|
4136
4155
|
function sampleObservable(source, sampler) {
|
4137
|
-
|
4156
|
+
|
4138
4157
|
return new AnonymousObservable(function (observer) {
|
4139
4158
|
var atEnd, value, hasValue;
|
4140
4159
|
|
@@ -4160,12 +4179,12 @@ if (!Array.prototype.forEach) {
|
|
4160
4179
|
|
4161
4180
|
/**
|
4162
4181
|
* Samples the observable sequence at each interval.
|
4163
|
-
*
|
4182
|
+
*
|
4164
4183
|
* @example
|
4165
4184
|
* 1 - res = source.sample(sampleObservable); // Sampler tick sequence
|
4166
4185
|
* 2 - res = source.sample(5000); // 5 seconds
|
4167
4186
|
* 2 - res = source.sample(5000, Rx.Scheduler.timeout); // 5 seconds
|
4168
|
-
*
|
4187
|
+
*
|
4169
4188
|
* @param {Mixed} intervalOrSampler Interval at which to sample (specified as an integer denoting milliseconds) or Sampler Observable.
|
4170
4189
|
* @param {Scheduler} [scheduler] Scheduler to run the sampling timer on. If not specified, the timeout scheduler is used.
|
4171
4190
|
* @returns {Observable} Sampled observable sequence.
|
@@ -4178,7 +4197,7 @@ if (!Array.prototype.forEach) {
|
|
4178
4197
|
};
|
4179
4198
|
|
4180
4199
|
/**
|
4181
|
-
* Returns the source observable sequence or the other observable sequence if dueTime elapses.
|
4200
|
+
* Returns the source observable sequence or the other observable sequence if dueTime elapses.
|
4182
4201
|
* @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) when a timeout occurs.
|
4183
4202
|
* @param {Observable} [other] Sequence to return in case of a timeout. If not specified, a timeout error throwing sequence will be used.
|
4184
4203
|
* @param {Scheduler} [scheduler] Scheduler to run the timeout timers on. If not specified, the timeout scheduler is used.
|
@@ -4187,7 +4206,7 @@ if (!Array.prototype.forEach) {
|
|
4187
4206
|
observableProto.timeout = function (dueTime, other, scheduler) {
|
4188
4207
|
other || (other = observableThrow(new Error('Timeout')));
|
4189
4208
|
isScheduler(scheduler) || (scheduler = timeoutScheduler);
|
4190
|
-
|
4209
|
+
|
4191
4210
|
var source = this, schedulerMethod = dueTime instanceof Date ?
|
4192
4211
|
'scheduleWithAbsolute' :
|
4193
4212
|
'scheduleWithRelative';
|
@@ -4212,7 +4231,7 @@ if (!Array.prototype.forEach) {
|
|
4212
4231
|
}
|
4213
4232
|
|
4214
4233
|
createTimer();
|
4215
|
-
|
4234
|
+
|
4216
4235
|
original.setDisposable(source.subscribe(function (x) {
|
4217
4236
|
if (!switched) {
|
4218
4237
|
id++;
|
@@ -4234,199 +4253,6 @@ if (!Array.prototype.forEach) {
|
|
4234
4253
|
});
|
4235
4254
|
};
|
4236
4255
|
|
4237
|
-
/**
|
4238
|
-
* Time shifts the observable sequence by delaying the subscription.
|
4239
|
-
*
|
4240
|
-
* @example
|
4241
|
-
* 1 - res = source.delaySubscription(5000); // 5s
|
4242
|
-
* 2 - res = source.delaySubscription(5000, Rx.Scheduler.timeout); // 5 seconds
|
4243
|
-
*
|
4244
|
-
* @param {Number} dueTime Absolute or relative time to perform the subscription at.
|
4245
|
-
* @param {Scheduler} [scheduler] Scheduler to run the subscription delay timer on. If not specified, the timeout scheduler is used.
|
4246
|
-
* @returns {Observable} Time-shifted sequence.
|
4247
|
-
*/
|
4248
|
-
observableProto.delaySubscription = function (dueTime, scheduler) {
|
4249
|
-
return this.delayWithSelector(observableTimer(dueTime, isScheduler(scheduler) ? scheduler : timeoutScheduler), observableEmpty);
|
4250
|
-
};
|
4251
|
-
|
4252
|
-
/**
|
4253
|
-
* Time shifts the observable sequence based on a subscription delay and a delay selector function for each element.
|
4254
|
-
*
|
4255
|
-
* @example
|
4256
|
-
* 1 - res = source.delayWithSelector(function (x) { return Rx.Scheduler.timer(5000); }); // with selector only
|
4257
|
-
* 1 - res = source.delayWithSelector(Rx.Observable.timer(2000), function (x) { return Rx.Observable.timer(x); }); // with delay and selector
|
4258
|
-
*
|
4259
|
-
* @param {Observable} [subscriptionDelay] Sequence indicating the delay for the subscription to the source.
|
4260
|
-
* @param {Function} delayDurationSelector Selector function to retrieve a sequence indicating the delay for each given element.
|
4261
|
-
* @returns {Observable} Time-shifted sequence.
|
4262
|
-
*/
|
4263
|
-
observableProto.delayWithSelector = function (subscriptionDelay, delayDurationSelector) {
|
4264
|
-
var source = this, subDelay, selector;
|
4265
|
-
if (typeof subscriptionDelay === 'function') {
|
4266
|
-
selector = subscriptionDelay;
|
4267
|
-
} else {
|
4268
|
-
subDelay = subscriptionDelay;
|
4269
|
-
selector = delayDurationSelector;
|
4270
|
-
}
|
4271
|
-
return new AnonymousObservable(function (observer) {
|
4272
|
-
var delays = new CompositeDisposable(), atEnd = false, done = function () {
|
4273
|
-
if (atEnd && delays.length === 0) {
|
4274
|
-
observer.onCompleted();
|
4275
|
-
}
|
4276
|
-
}, subscription = new SerialDisposable(), start = function () {
|
4277
|
-
subscription.setDisposable(source.subscribe(function (x) {
|
4278
|
-
var delay;
|
4279
|
-
try {
|
4280
|
-
delay = selector(x);
|
4281
|
-
} catch (error) {
|
4282
|
-
observer.onError(error);
|
4283
|
-
return;
|
4284
|
-
}
|
4285
|
-
var d = new SingleAssignmentDisposable();
|
4286
|
-
delays.add(d);
|
4287
|
-
d.setDisposable(delay.subscribe(function () {
|
4288
|
-
observer.onNext(x);
|
4289
|
-
delays.remove(d);
|
4290
|
-
done();
|
4291
|
-
}, observer.onError.bind(observer), function () {
|
4292
|
-
observer.onNext(x);
|
4293
|
-
delays.remove(d);
|
4294
|
-
done();
|
4295
|
-
}));
|
4296
|
-
}, observer.onError.bind(observer), function () {
|
4297
|
-
atEnd = true;
|
4298
|
-
subscription.dispose();
|
4299
|
-
done();
|
4300
|
-
}));
|
4301
|
-
};
|
4302
|
-
|
4303
|
-
if (!subDelay) {
|
4304
|
-
start();
|
4305
|
-
} else {
|
4306
|
-
subscription.setDisposable(subDelay.subscribe(function () {
|
4307
|
-
start();
|
4308
|
-
}, observer.onError.bind(observer), function () { start(); }));
|
4309
|
-
}
|
4310
|
-
|
4311
|
-
return new CompositeDisposable(subscription, delays);
|
4312
|
-
});
|
4313
|
-
};
|
4314
|
-
|
4315
|
-
/**
|
4316
|
-
* Skips elements for the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.
|
4317
|
-
*
|
4318
|
-
* 1 - res = source.skipLastWithTime(5000);
|
4319
|
-
* 2 - res = source.skipLastWithTime(5000, scheduler);
|
4320
|
-
*
|
4321
|
-
* @description
|
4322
|
-
* This operator accumulates a queue with a length enough to store elements received during the initial duration window.
|
4323
|
-
* As more elements are received, elements older than the specified duration are taken from the queue and produced on the
|
4324
|
-
* result sequence. This causes elements to be delayed with duration.
|
4325
|
-
* @param {Number} duration Duration for skipping elements from the end of the sequence.
|
4326
|
-
* @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout
|
4327
|
-
* @returns {Observable} An observable sequence with the elements skipped during the specified duration from the end of the source sequence.
|
4328
|
-
*/
|
4329
|
-
observableProto.skipLastWithTime = function (duration, scheduler) {
|
4330
|
-
isScheduler(scheduler) || (scheduler = timeoutScheduler);
|
4331
|
-
var source = this;
|
4332
|
-
return new AnonymousObservable(function (observer) {
|
4333
|
-
var q = [];
|
4334
|
-
return source.subscribe(function (x) {
|
4335
|
-
var now = scheduler.now();
|
4336
|
-
q.push({ interval: now, value: x });
|
4337
|
-
while (q.length > 0 && now - q[0].interval >= duration) {
|
4338
|
-
observer.onNext(q.shift().value);
|
4339
|
-
}
|
4340
|
-
}, observer.onError.bind(observer), function () {
|
4341
|
-
var now = scheduler.now();
|
4342
|
-
while (q.length > 0 && now - q[0].interval >= duration) {
|
4343
|
-
observer.onNext(q.shift().value);
|
4344
|
-
}
|
4345
|
-
observer.onCompleted();
|
4346
|
-
});
|
4347
|
-
});
|
4348
|
-
};
|
4349
|
-
|
4350
|
-
/**
|
4351
|
-
* Returns elements within the specified duration from the end of the observable source sequence, using the specified schedulers to run timers and to drain the collected elements.
|
4352
|
-
* @description
|
4353
|
-
* This operator accumulates a queue with a length enough to store elements received during the initial duration window.
|
4354
|
-
* As more elements are received, elements older than the specified duration are taken from the queue and produced on the
|
4355
|
-
* result sequence. This causes elements to be delayed with duration.
|
4356
|
-
* @param {Number} duration Duration for taking elements from the end of the sequence.
|
4357
|
-
* @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.
|
4358
|
-
* @returns {Observable} An observable sequence with the elements taken during the specified duration from the end of the source sequence.
|
4359
|
-
*/
|
4360
|
-
observableProto.takeLastWithTime = function (duration, scheduler) {
|
4361
|
-
var source = this;
|
4362
|
-
isScheduler(scheduler) || (scheduler = timeoutScheduler);
|
4363
|
-
return new AnonymousObservable(function (observer) {
|
4364
|
-
var q = [];
|
4365
|
-
return source.subscribe(function (x) {
|
4366
|
-
var now = scheduler.now();
|
4367
|
-
q.push({ interval: now, value: x });
|
4368
|
-
while (q.length > 0 && now - q[0].interval >= duration) {
|
4369
|
-
q.shift();
|
4370
|
-
}
|
4371
|
-
}, observer.onError.bind(observer), function () {
|
4372
|
-
var now = scheduler.now();
|
4373
|
-
while (q.length > 0) {
|
4374
|
-
var next = q.shift();
|
4375
|
-
if (now - next.interval <= duration) { observer.onNext(next.value); }
|
4376
|
-
}
|
4377
|
-
observer.onCompleted();
|
4378
|
-
});
|
4379
|
-
});
|
4380
|
-
};
|
4381
|
-
|
4382
|
-
/**
|
4383
|
-
* Takes elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.
|
4384
|
-
*
|
4385
|
-
* @example
|
4386
|
-
* 1 - res = source.takeWithTime(5000, [optional scheduler]);
|
4387
|
-
* @description
|
4388
|
-
* This operator accumulates a queue with a length enough to store elements received during the initial duration window.
|
4389
|
-
* As more elements are received, elements older than the specified duration are taken from the queue and produced on the
|
4390
|
-
* result sequence. This causes elements to be delayed with duration.
|
4391
|
-
* @param {Number} duration Duration for taking elements from the start of the sequence.
|
4392
|
-
* @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.
|
4393
|
-
* @returns {Observable} An observable sequence with the elements taken during the specified duration from the start of the source sequence.
|
4394
|
-
*/
|
4395
|
-
observableProto.takeWithTime = function (duration, scheduler) {
|
4396
|
-
var source = this;
|
4397
|
-
isScheduler(scheduler) || (scheduler = timeoutScheduler);
|
4398
|
-
return new AnonymousObservable(function (observer) {
|
4399
|
-
return new CompositeDisposable(scheduler.scheduleWithRelative(duration, observer.onCompleted.bind(observer)), source.subscribe(observer));
|
4400
|
-
});
|
4401
|
-
};
|
4402
|
-
|
4403
|
-
/**
|
4404
|
-
* Skips elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.
|
4405
|
-
*
|
4406
|
-
* @example
|
4407
|
-
* 1 - res = source.skipWithTime(5000, [optional scheduler]);
|
4408
|
-
*
|
4409
|
-
* @description
|
4410
|
-
* Specifying a zero value for duration doesn't guarantee no elements will be dropped from the start of the source sequence.
|
4411
|
-
* This is a side-effect of the asynchrony introduced by the scheduler, where the action that causes callbacks from the source sequence to be forwarded
|
4412
|
-
* may not execute immediately, despite the zero due time.
|
4413
|
-
*
|
4414
|
-
* Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the duration.
|
4415
|
-
* @param {Number} duration Duration for skipping elements from the start of the sequence.
|
4416
|
-
* @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.
|
4417
|
-
* @returns {Observable} An observable sequence with the elements skipped during the specified duration from the start of the source sequence.
|
4418
|
-
*/
|
4419
|
-
observableProto.skipWithTime = function (duration, scheduler) {
|
4420
|
-
var source = this;
|
4421
|
-
isScheduler(scheduler) || (scheduler = timeoutScheduler);
|
4422
|
-
return new AnonymousObservable(function (observer) {
|
4423
|
-
var open = false;
|
4424
|
-
return new CompositeDisposable(
|
4425
|
-
scheduler.scheduleWithRelative(duration, function () { open = true; }),
|
4426
|
-
source.subscribe(function (x) { open && observer.onNext(x); }, observer.onError.bind(observer), observer.onCompleted.bind(observer)));
|
4427
|
-
});
|
4428
|
-
};
|
4429
|
-
|
4430
4256
|
var PausableObservable = (function (_super) {
|
4431
4257
|
|
4432
4258
|
inherits(PausableObservable, _super);
|
@@ -4484,6 +4310,7 @@ if (!Array.prototype.forEach) {
|
|
4484
4310
|
observableProto.pausable = function (pauser) {
|
4485
4311
|
return new PausableObservable(this, pauser);
|
4486
4312
|
};
|
4313
|
+
|
4487
4314
|
function combineLatestSource(source, subject, resultSelector) {
|
4488
4315
|
return new AnonymousObservable(function (observer) {
|
4489
4316
|
var n = 2,
|
@@ -4534,13 +4361,13 @@ if (!Array.prototype.forEach) {
|
|
4534
4361
|
|
4535
4362
|
function subscribe(observer) {
|
4536
4363
|
var q = [], previousShouldFire;
|
4537
|
-
|
4538
|
-
var subscription =
|
4364
|
+
|
4365
|
+
var subscription =
|
4539
4366
|
combineLatestSource(
|
4540
4367
|
this.source,
|
4541
4368
|
this.pauser.distinctUntilChanged().startWith(false),
|
4542
4369
|
function (data, shouldFire) {
|
4543
|
-
return { data: data, shouldFire: shouldFire };
|
4370
|
+
return { data: data, shouldFire: shouldFire };
|
4544
4371
|
})
|
4545
4372
|
.subscribe(
|
4546
4373
|
function (results) {
|
@@ -4574,10 +4401,10 @@ if (!Array.prototype.forEach) {
|
|
4574
4401
|
while (q.length > 0) {
|
4575
4402
|
observer.onNext(q.shift());
|
4576
4403
|
}
|
4577
|
-
observer.onCompleted();
|
4404
|
+
observer.onCompleted();
|
4578
4405
|
}
|
4579
4406
|
);
|
4580
|
-
return subscription;
|
4407
|
+
return subscription;
|
4581
4408
|
}
|
4582
4409
|
|
4583
4410
|
function PausableBufferedObservable(source, pauser) {
|
@@ -4601,7 +4428,7 @@ if (!Array.prototype.forEach) {
|
|
4601
4428
|
this.controller.onNext(true);
|
4602
4429
|
};
|
4603
4430
|
|
4604
|
-
return PausableBufferedObservable;
|
4431
|
+
return PausableBufferedObservable;
|
4605
4432
|
|
4606
4433
|
}(Observable));
|
4607
4434
|
|
@@ -4613,7 +4440,7 @@ if (!Array.prototype.forEach) {
|
|
4613
4440
|
* var source = Rx.Observable.interval(100).pausableBuffered(pauser);
|
4614
4441
|
* @param {Observable} pauser The observable sequence used to pause the underlying sequence.
|
4615
4442
|
* @returns {Observable} The observable sequence which is paused based upon the pauser.
|
4616
|
-
*/
|
4443
|
+
*/
|
4617
4444
|
observableProto.pausableBuffered = function (subject) {
|
4618
4445
|
return new PausableBufferedObservable(this, subject);
|
4619
4446
|
};
|
@@ -4625,11 +4452,12 @@ if (!Array.prototype.forEach) {
|
|
4625
4452
|
* source.request(3); // Reads 3 values
|
4626
4453
|
* @param {Observable} pauser The observable sequence used to pause the underlying sequence.
|
4627
4454
|
* @returns {Observable} The observable sequence which is paused based upon the pauser.
|
4628
|
-
*/
|
4455
|
+
*/
|
4629
4456
|
observableProto.controlled = function (enableQueue) {
|
4630
4457
|
if (enableQueue == null) { enableQueue = true; }
|
4631
4458
|
return new ControlledObservable(this, enableQueue);
|
4632
4459
|
};
|
4460
|
+
|
4633
4461
|
var ControlledObservable = (function (_super) {
|
4634
4462
|
|
4635
4463
|
inherits(ControlledObservable, _super);
|
@@ -4694,7 +4522,7 @@ if (!Array.prototype.forEach) {
|
|
4694
4522
|
|
4695
4523
|
if (!this.enableQueue || this.queue.length === 0) {
|
4696
4524
|
this.subject.onError(error);
|
4697
|
-
}
|
4525
|
+
}
|
4698
4526
|
},
|
4699
4527
|
onNext: function (value) {
|
4700
4528
|
checkDisposed.call(this);
|
@@ -4741,7 +4569,7 @@ if (!Array.prototype.forEach) {
|
|
4741
4569
|
} else if (this.hasCompleted) {
|
4742
4570
|
this.subject.onCompleted();
|
4743
4571
|
this.controlledDisposable.dispose();
|
4744
|
-
this.controlledDisposable = disposableEmpty;
|
4572
|
+
this.controlledDisposable = disposableEmpty;
|
4745
4573
|
}
|
4746
4574
|
|
4747
4575
|
return { numberOfItems: numberOfItems, returnValue: false };
|
@@ -4779,6 +4607,7 @@ if (!Array.prototype.forEach) {
|
|
4779
4607
|
|
4780
4608
|
return ControlledSubject;
|
4781
4609
|
}(Observable));
|
4610
|
+
|
4782
4611
|
/*
|
4783
4612
|
* Performs a exclusive waiting for the first to finish before subscribing to another observable.
|
4784
4613
|
* Observables that come in between subscriptions will be dropped on the floor.
|
@@ -4798,7 +4627,7 @@ if (!Array.prototype.forEach) {
|
|
4798
4627
|
function (innerSource) {
|
4799
4628
|
if (!hasCurrent) {
|
4800
4629
|
hasCurrent = true;
|
4801
|
-
|
4630
|
+
|
4802
4631
|
isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
|
4803
4632
|
|
4804
4633
|
var innerSubscription = new SingleAssignmentDisposable();
|
@@ -4819,7 +4648,7 @@ if (!Array.prototype.forEach) {
|
|
4819
4648
|
observer.onError.bind(observer),
|
4820
4649
|
function () {
|
4821
4650
|
isStopped = true;
|
4822
|
-
if (!hasCurrent && g.length === 1) {
|
4651
|
+
if (!hasCurrent && g.length === 1) {
|
4823
4652
|
observer.onCompleted();
|
4824
4653
|
}
|
4825
4654
|
}));
|
@@ -4827,6 +4656,7 @@ if (!Array.prototype.forEach) {
|
|
4827
4656
|
return g;
|
4828
4657
|
});
|
4829
4658
|
};
|
4659
|
+
|
4830
4660
|
/*
|
4831
4661
|
* Performs a exclusive map waiting for the first to finish before subscribing to another observable.
|
4832
4662
|
* Observables that come in between subscriptions will be dropped on the floor.
|
@@ -4849,12 +4679,12 @@ if (!Array.prototype.forEach) {
|
|
4849
4679
|
function (innerSource) {
|
4850
4680
|
|
4851
4681
|
if (!hasCurrent) {
|
4852
|
-
hasCurrent = true;
|
4682
|
+
hasCurrent = true;
|
4853
4683
|
|
4854
4684
|
innerSubscription = new SingleAssignmentDisposable();
|
4855
4685
|
g.add(innerSubscription);
|
4856
4686
|
|
4857
|
-
isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
|
4687
|
+
isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
|
4858
4688
|
|
4859
4689
|
innerSubscription.setDisposable(innerSource.subscribe(
|
4860
4690
|
function (x) {
|
@@ -4878,7 +4708,7 @@ if (!Array.prototype.forEach) {
|
|
4878
4708
|
}
|
4879
4709
|
}));
|
4880
4710
|
}
|
4881
|
-
},
|
4711
|
+
},
|
4882
4712
|
observer.onError.bind(observer),
|
4883
4713
|
function () {
|
4884
4714
|
isStopped = true;
|
@@ -4889,6 +4719,7 @@ if (!Array.prototype.forEach) {
|
|
4889
4719
|
return g;
|
4890
4720
|
});
|
4891
4721
|
};
|
4722
|
+
|
4892
4723
|
var AnonymousObservable = Rx.AnonymousObservable = (function (__super__) {
|
4893
4724
|
inherits(AnonymousObservable, __super__);
|
4894
4725
|
|
@@ -4913,7 +4744,7 @@ if (!Array.prototype.forEach) {
|
|
4913
4744
|
} catch (e) {
|
4914
4745
|
if (!autoDetachObserver.fail(e)) {
|
4915
4746
|
throw e;
|
4916
|
-
}
|
4747
|
+
}
|
4917
4748
|
}
|
4918
4749
|
};
|
4919
4750
|
|
@@ -4951,8 +4782,8 @@ if (!Array.prototype.forEach) {
|
|
4951
4782
|
try {
|
4952
4783
|
this.observer.onNext(value);
|
4953
4784
|
noError = true;
|
4954
|
-
} catch (e) {
|
4955
|
-
throw e;
|
4785
|
+
} catch (e) {
|
4786
|
+
throw e;
|
4956
4787
|
} finally {
|
4957
4788
|
if (!noError) {
|
4958
4789
|
this.dispose();
|
@@ -4963,8 +4794,8 @@ if (!Array.prototype.forEach) {
|
|
4963
4794
|
AutoDetachObserverPrototype.error = function (exn) {
|
4964
4795
|
try {
|
4965
4796
|
this.observer.onError(exn);
|
4966
|
-
} catch (e) {
|
4967
|
-
throw e;
|
4797
|
+
} catch (e) {
|
4798
|
+
throw e;
|
4968
4799
|
} finally {
|
4969
4800
|
this.dispose();
|
4970
4801
|
}
|
@@ -4973,8 +4804,8 @@ if (!Array.prototype.forEach) {
|
|
4973
4804
|
AutoDetachObserverPrototype.completed = function () {
|
4974
4805
|
try {
|
4975
4806
|
this.observer.onCompleted();
|
4976
|
-
} catch (e) {
|
4977
|
-
throw e;
|
4807
|
+
} catch (e) {
|
4808
|
+
throw e;
|
4978
4809
|
} finally {
|
4979
4810
|
this.dispose();
|
4980
4811
|
}
|
@@ -4995,23 +4826,23 @@ if (!Array.prototype.forEach) {
|
|
4995
4826
|
return AutoDetachObserver;
|
4996
4827
|
}(AbstractObserver));
|
4997
4828
|
|
4998
|
-
/** @private */
|
4999
|
-
var InnerSubscription = function (subject, observer) {
|
5000
|
-
this.subject = subject;
|
5001
|
-
this.observer = observer;
|
5002
|
-
};
|
5003
|
-
|
5004
|
-
/**
|
5005
|
-
* @private
|
5006
|
-
* @memberOf InnerSubscription
|
5007
|
-
*/
|
5008
|
-
InnerSubscription.prototype.dispose = function () {
|
5009
|
-
if (!this.subject.isDisposed && this.observer !== null) {
|
5010
|
-
var idx = this.subject.observers.indexOf(this.observer);
|
5011
|
-
this.subject.observers.splice(idx, 1);
|
5012
|
-
this.observer = null;
|
5013
|
-
}
|
5014
|
-
};
|
4829
|
+
/** @private */
|
4830
|
+
var InnerSubscription = function (subject, observer) {
|
4831
|
+
this.subject = subject;
|
4832
|
+
this.observer = observer;
|
4833
|
+
};
|
4834
|
+
|
4835
|
+
/**
|
4836
|
+
* @private
|
4837
|
+
* @memberOf InnerSubscription
|
4838
|
+
*/
|
4839
|
+
InnerSubscription.prototype.dispose = function () {
|
4840
|
+
if (!this.subject.isDisposed && this.observer !== null) {
|
4841
|
+
var idx = this.subject.observers.indexOf(this.observer);
|
4842
|
+
this.subject.observers.splice(idx, 1);
|
4843
|
+
this.observer = null;
|
4844
|
+
}
|
4845
|
+
};
|
5015
4846
|
|
5016
4847
|
/**
|
5017
4848
|
* Represents an object that is both an observable sequence as well as an observer.
|
@@ -5037,7 +4868,7 @@ if (!Array.prototype.forEach) {
|
|
5037
4868
|
/**
|
5038
4869
|
* Creates a subject.
|
5039
4870
|
* @constructor
|
5040
|
-
*/
|
4871
|
+
*/
|
5041
4872
|
function Subject() {
|
5042
4873
|
_super.call(this, subscribe);
|
5043
4874
|
this.isDisposed = false,
|
@@ -5049,13 +4880,13 @@ if (!Array.prototype.forEach) {
|
|
5049
4880
|
/**
|
5050
4881
|
* Indicates whether the subject has observers subscribed to it.
|
5051
4882
|
* @returns {Boolean} Indicates whether the subject has observers subscribed to it.
|
5052
|
-
*/
|
4883
|
+
*/
|
5053
4884
|
hasObservers: function () {
|
5054
4885
|
return this.observers.length > 0;
|
5055
4886
|
},
|
5056
4887
|
/**
|
5057
4888
|
* Notifies all subscribed observers about the end of the sequence.
|
5058
|
-
*/
|
4889
|
+
*/
|
5059
4890
|
onCompleted: function () {
|
5060
4891
|
checkDisposed.call(this);
|
5061
4892
|
if (!this.isStopped) {
|
@@ -5071,7 +4902,7 @@ if (!Array.prototype.forEach) {
|
|
5071
4902
|
/**
|
5072
4903
|
* Notifies all subscribed observers about the exception.
|
5073
4904
|
* @param {Mixed} error The exception to send to all observers.
|
5074
|
-
*/
|
4905
|
+
*/
|
5075
4906
|
onError: function (exception) {
|
5076
4907
|
checkDisposed.call(this);
|
5077
4908
|
if (!this.isStopped) {
|
@@ -5088,7 +4919,7 @@ if (!Array.prototype.forEach) {
|
|
5088
4919
|
/**
|
5089
4920
|
* Notifies all subscribed observers about the arrival of the specified element in the sequence.
|
5090
4921
|
* @param {Mixed} value The value to send to all observers.
|
5091
|
-
*/
|
4922
|
+
*/
|
5092
4923
|
onNext: function (value) {
|
5093
4924
|
checkDisposed.call(this);
|
5094
4925
|
if (!this.isStopped) {
|
@@ -5100,7 +4931,7 @@ if (!Array.prototype.forEach) {
|
|
5100
4931
|
},
|
5101
4932
|
/**
|
5102
4933
|
* Unsubscribe all observers and release resources.
|
5103
|
-
*/
|
4934
|
+
*/
|
5104
4935
|
dispose: function () {
|
5105
4936
|
this.isDisposed = true;
|
5106
4937
|
this.observers = null;
|
@@ -5123,12 +4954,12 @@ if (!Array.prototype.forEach) {
|
|
5123
4954
|
/**
|
5124
4955
|
* Represents the result of an asynchronous operation.
|
5125
4956
|
* The last value before the OnCompleted notification, or the error received through OnError, is sent to all subscribed observers.
|
5126
|
-
*/
|
4957
|
+
*/
|
5127
4958
|
var AsyncSubject = Rx.AsyncSubject = (function (__super__) {
|
5128
4959
|
|
5129
4960
|
function subscribe(observer) {
|
5130
4961
|
checkDisposed.call(this);
|
5131
|
-
|
4962
|
+
|
5132
4963
|
if (!this.isStopped) {
|
5133
4964
|
this.observers.push(observer);
|
5134
4965
|
return new InnerSubscription(this, observer);
|
@@ -5155,7 +4986,7 @@ if (!Array.prototype.forEach) {
|
|
5155
4986
|
/**
|
5156
4987
|
* Creates a subject that can only receive one value and that value is cached for all future observations.
|
5157
4988
|
* @constructor
|
5158
|
-
*/
|
4989
|
+
*/
|
5159
4990
|
function AsyncSubject() {
|
5160
4991
|
__super__.call(this, subscribe);
|
5161
4992
|
|
@@ -5171,14 +5002,14 @@ if (!Array.prototype.forEach) {
|
|
5171
5002
|
/**
|
5172
5003
|
* Indicates whether the subject has observers subscribed to it.
|
5173
5004
|
* @returns {Boolean} Indicates whether the subject has observers subscribed to it.
|
5174
|
-
*/
|
5005
|
+
*/
|
5175
5006
|
hasObservers: function () {
|
5176
5007
|
checkDisposed.call(this);
|
5177
5008
|
return this.observers.length > 0;
|
5178
5009
|
},
|
5179
5010
|
/**
|
5180
5011
|
* Notifies all subscribed observers about the end of the sequence, also causing the last received value to be sent out (if any).
|
5181
|
-
*/
|
5012
|
+
*/
|
5182
5013
|
onCompleted: function () {
|
5183
5014
|
var o, i, len;
|
5184
5015
|
checkDisposed.call(this);
|
@@ -5206,7 +5037,7 @@ if (!Array.prototype.forEach) {
|
|
5206
5037
|
/**
|
5207
5038
|
* Notifies all subscribed observers about the error.
|
5208
5039
|
* @param {Mixed} error The Error to send to all observers.
|
5209
|
-
*/
|
5040
|
+
*/
|
5210
5041
|
onError: function (error) {
|
5211
5042
|
checkDisposed.call(this);
|
5212
5043
|
if (!this.isStopped) {
|
@@ -5224,7 +5055,7 @@ if (!Array.prototype.forEach) {
|
|
5224
5055
|
/**
|
5225
5056
|
* Sends a value to the subject. The last value received before successful termination will be sent to all subscribed and future observers.
|
5226
5057
|
* @param {Mixed} value The value to store in the subject.
|
5227
|
-
*/
|
5058
|
+
*/
|
5228
5059
|
onNext: function (value) {
|
5229
5060
|
checkDisposed.call(this);
|
5230
5061
|
if (this.isStopped) { return; }
|
@@ -5245,29 +5076,29 @@ if (!Array.prototype.forEach) {
|
|
5245
5076
|
return AsyncSubject;
|
5246
5077
|
}(Observable));
|
5247
5078
|
|
5248
|
-
var AnonymousSubject = Rx.AnonymousSubject = (function (__super__) {
|
5249
|
-
inherits(AnonymousSubject, __super__);
|
5250
|
-
|
5251
|
-
function AnonymousSubject(observer, observable) {
|
5252
|
-
this.observer = observer;
|
5253
|
-
this.observable = observable;
|
5254
|
-
__super__.call(this, this.observable.subscribe.bind(this.observable));
|
5255
|
-
}
|
5256
|
-
|
5257
|
-
addProperties(AnonymousSubject.prototype, Observer, {
|
5258
|
-
onCompleted: function () {
|
5259
|
-
this.observer.onCompleted();
|
5260
|
-
},
|
5261
|
-
onError: function (exception) {
|
5262
|
-
this.observer.onError(exception);
|
5263
|
-
},
|
5264
|
-
onNext: function (value) {
|
5265
|
-
this.observer.onNext(value);
|
5266
|
-
}
|
5267
|
-
});
|
5268
|
-
|
5269
|
-
return AnonymousSubject;
|
5270
|
-
}(Observable));
|
5079
|
+
var AnonymousSubject = Rx.AnonymousSubject = (function (__super__) {
|
5080
|
+
inherits(AnonymousSubject, __super__);
|
5081
|
+
|
5082
|
+
function AnonymousSubject(observer, observable) {
|
5083
|
+
this.observer = observer;
|
5084
|
+
this.observable = observable;
|
5085
|
+
__super__.call(this, this.observable.subscribe.bind(this.observable));
|
5086
|
+
}
|
5087
|
+
|
5088
|
+
addProperties(AnonymousSubject.prototype, Observer, {
|
5089
|
+
onCompleted: function () {
|
5090
|
+
this.observer.onCompleted();
|
5091
|
+
},
|
5092
|
+
onError: function (exception) {
|
5093
|
+
this.observer.onError(exception);
|
5094
|
+
},
|
5095
|
+
onNext: function (value) {
|
5096
|
+
this.observer.onNext(value);
|
5097
|
+
}
|
5098
|
+
});
|
5099
|
+
|
5100
|
+
return AnonymousSubject;
|
5101
|
+
}(Observable));
|
5271
5102
|
|
5272
5103
|
/**
|
5273
5104
|
* Represents a value that changes over time.
|
@@ -5296,7 +5127,7 @@ if (!Array.prototype.forEach) {
|
|
5296
5127
|
* @constructor
|
5297
5128
|
* Initializes a new instance of the BehaviorSubject class which creates a subject that caches its last value and starts with the specified value.
|
5298
5129
|
* @param {Mixed} value Initial value sent to observers when no other value has been received by the subject yet.
|
5299
|
-
*/
|
5130
|
+
*/
|
5300
5131
|
function BehaviorSubject(value) {
|
5301
5132
|
__super__.call(this, subscribe);
|
5302
5133
|
this.value = value,
|
@@ -5310,13 +5141,13 @@ if (!Array.prototype.forEach) {
|
|
5310
5141
|
/**
|
5311
5142
|
* Indicates whether the subject has observers subscribed to it.
|
5312
5143
|
* @returns {Boolean} Indicates whether the subject has observers subscribed to it.
|
5313
|
-
*/
|
5144
|
+
*/
|
5314
5145
|
hasObservers: function () {
|
5315
5146
|
return this.observers.length > 0;
|
5316
5147
|
},
|
5317
5148
|
/**
|
5318
5149
|
* Notifies all subscribed observers about the end of the sequence.
|
5319
|
-
*/
|
5150
|
+
*/
|
5320
5151
|
onCompleted: function () {
|
5321
5152
|
checkDisposed.call(this);
|
5322
5153
|
if (this.isStopped) { return; }
|
@@ -5330,7 +5161,7 @@ if (!Array.prototype.forEach) {
|
|
5330
5161
|
/**
|
5331
5162
|
* Notifies all subscribed observers about the exception.
|
5332
5163
|
* @param {Mixed} error The exception to send to all observers.
|
5333
|
-
*/
|
5164
|
+
*/
|
5334
5165
|
onError: function (error) {
|
5335
5166
|
checkDisposed.call(this);
|
5336
5167
|
if (this.isStopped) { return; }
|
@@ -5346,7 +5177,7 @@ if (!Array.prototype.forEach) {
|
|
5346
5177
|
/**
|
5347
5178
|
* Notifies all subscribed observers about the arrival of the specified element in the sequence.
|
5348
5179
|
* @param {Mixed} value The value to send to all observers.
|
5349
|
-
*/
|
5180
|
+
*/
|
5350
5181
|
onNext: function (value) {
|
5351
5182
|
checkDisposed.call(this);
|
5352
5183
|
if (this.isStopped) { return; }
|
@@ -5357,7 +5188,7 @@ if (!Array.prototype.forEach) {
|
|
5357
5188
|
},
|
5358
5189
|
/**
|
5359
5190
|
* Unsubscribe all observers and release resources.
|
5360
|
-
*/
|
5191
|
+
*/
|
5361
5192
|
dispose: function () {
|
5362
5193
|
this.isDisposed = true;
|
5363
5194
|
this.observers = null;
|
@@ -5372,7 +5203,7 @@ if (!Array.prototype.forEach) {
|
|
5372
5203
|
/**
|
5373
5204
|
* Represents an object that is both an observable sequence as well as an observer.
|
5374
5205
|
* Each notification is broadcasted to all subscribed and future observers, subject to buffer trimming policies.
|
5375
|
-
*/
|
5206
|
+
*/
|
5376
5207
|
var ReplaySubject = Rx.ReplaySubject = (function (__super__) {
|
5377
5208
|
|
5378
5209
|
function createRemovableDisposable(subject, observer) {
|
@@ -5432,7 +5263,7 @@ if (!Array.prototype.forEach) {
|
|
5432
5263
|
/**
|
5433
5264
|
* Indicates whether the subject has observers subscribed to it.
|
5434
5265
|
* @returns {Boolean} Indicates whether the subject has observers subscribed to it.
|
5435
|
-
*/
|
5266
|
+
*/
|
5436
5267
|
hasObservers: function () {
|
5437
5268
|
return this.observers.length > 0;
|
5438
5269
|
},
|
@@ -5447,7 +5278,7 @@ if (!Array.prototype.forEach) {
|
|
5447
5278
|
/**
|
5448
5279
|
* Notifies all subscribed observers about the arrival of the specified element in the sequence.
|
5449
5280
|
* @param {Mixed} value The value to send to all observers.
|
5450
|
-
*/
|
5281
|
+
*/
|
5451
5282
|
onNext: function (value) {
|
5452
5283
|
checkDisposed.call(this);
|
5453
5284
|
if (this.isStopped) { return; }
|
@@ -5465,7 +5296,7 @@ if (!Array.prototype.forEach) {
|
|
5465
5296
|
/**
|
5466
5297
|
* Notifies all subscribed observers about the exception.
|
5467
5298
|
* @param {Mixed} error The exception to send to all observers.
|
5468
|
-
*/
|
5299
|
+
*/
|
5469
5300
|
onError: function (error) {
|
5470
5301
|
checkDisposed.call(this);
|
5471
5302
|
if (this.isStopped) { return; }
|
@@ -5484,7 +5315,7 @@ if (!Array.prototype.forEach) {
|
|
5484
5315
|
},
|
5485
5316
|
/**
|
5486
5317
|
* Notifies all subscribed observers about the end of the sequence.
|
5487
|
-
*/
|
5318
|
+
*/
|
5488
5319
|
onCompleted: function () {
|
5489
5320
|
checkDisposed.call(this);
|
5490
5321
|
if (this.isStopped) { return; }
|
@@ -5501,7 +5332,7 @@ if (!Array.prototype.forEach) {
|
|
5501
5332
|
},
|
5502
5333
|
/**
|
5503
5334
|
* Unsubscribe all observers and release resources.
|
5504
|
-
*/
|
5335
|
+
*/
|
5505
5336
|
dispose: function () {
|
5506
5337
|
this.isDisposed = true;
|
5507
5338
|
this.observers = null;
|
@@ -5511,21 +5342,22 @@ if (!Array.prototype.forEach) {
|
|
5511
5342
|
return ReplaySubject;
|
5512
5343
|
}(Observable));
|
5513
5344
|
|
5514
|
-
if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
|
5515
|
-
root.Rx = Rx;
|
5516
|
-
|
5517
|
-
define(function() {
|
5518
|
-
return Rx;
|
5519
|
-
});
|
5520
|
-
} else if (freeExports && freeModule) {
|
5521
|
-
// in Node.js or RingoJS
|
5522
|
-
if (moduleExports) {
|
5523
|
-
(freeModule.exports = Rx).Rx = Rx;
|
5524
|
-
} else {
|
5525
|
-
freeExports.Rx = Rx;
|
5526
|
-
}
|
5527
|
-
} else {
|
5528
|
-
// in a browser or Rhino
|
5529
|
-
root.Rx = Rx;
|
5345
|
+
if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
|
5346
|
+
root.Rx = Rx;
|
5347
|
+
|
5348
|
+
define(function() {
|
5349
|
+
return Rx;
|
5350
|
+
});
|
5351
|
+
} else if (freeExports && freeModule) {
|
5352
|
+
// in Node.js or RingoJS
|
5353
|
+
if (moduleExports) {
|
5354
|
+
(freeModule.exports = Rx).Rx = Rx;
|
5355
|
+
} else {
|
5356
|
+
freeExports.Rx = Rx;
|
5357
|
+
}
|
5358
|
+
} else {
|
5359
|
+
// in a browser or Rhino
|
5360
|
+
root.Rx = Rx;
|
5530
5361
|
}
|
5531
|
-
|
5362
|
+
|
5363
|
+
}.call(this));
|