rxjs-rails 2.3.14 → 2.3.20
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 +325 -370
- data/vendor/assets/javascripts/rx.aggregates.min.js +1 -1
- data/vendor/assets/javascripts/rx.all.compat.js +1115 -930
- data/vendor/assets/javascripts/rx.all.compat.min.js +4 -3
- data/vendor/assets/javascripts/rx.all.js +1113 -928
- data/vendor/assets/javascripts/rx.all.min.js +3 -3
- data/vendor/assets/javascripts/rx.async.compat.js +16 -20
- data/vendor/assets/javascripts/rx.async.compat.min.js +1 -1
- data/vendor/assets/javascripts/rx.async.js +14 -18
- data/vendor/assets/javascripts/rx.async.min.js +1 -1
- data/vendor/assets/javascripts/rx.backpressure.js +26 -10
- data/vendor/assets/javascripts/rx.backpressure.min.js +1 -1
- data/vendor/assets/javascripts/rx.binding.js +2 -14
- data/vendor/assets/javascripts/rx.binding.min.js +1 -1
- data/vendor/assets/javascripts/rx.coincidence.js +13 -13
- data/vendor/assets/javascripts/rx.coincidence.min.js +1 -1
- data/vendor/assets/javascripts/rx.compat.js +586 -378
- data/vendor/assets/javascripts/rx.compat.min.js +2 -2
- data/vendor/assets/javascripts/rx.experimental.js +37 -29
- data/vendor/assets/javascripts/rx.experimental.min.js +1 -1
- data/vendor/assets/javascripts/rx.js +586 -378
- data/vendor/assets/javascripts/rx.lite.compat.js +632 -394
- data/vendor/assets/javascripts/rx.lite.compat.min.js +2 -2
- data/vendor/assets/javascripts/rx.lite.extras.js +29 -25
- data/vendor/assets/javascripts/rx.lite.extras.min.js +1 -1
- data/vendor/assets/javascripts/rx.lite.js +630 -392
- data/vendor/assets/javascripts/rx.lite.min.js +2 -2
- data/vendor/assets/javascripts/rx.min.js +2 -2
- data/vendor/assets/javascripts/rx.sorting.js +72 -0
- data/vendor/assets/javascripts/rx.sorting.min.js +3 -0
- data/vendor/assets/javascripts/rx.testing.js +116 -83
- data/vendor/assets/javascripts/rx.testing.min.js +1 -1
- data/vendor/assets/javascripts/rx.time.js +127 -101
- data/vendor/assets/javascripts/rx.time.min.js +1 -1
- metadata +4 -2
@@ -24,7 +24,7 @@
|
|
24
24
|
var Rx = {
|
25
25
|
internals: {},
|
26
26
|
config: {
|
27
|
-
Promise: root.Promise
|
27
|
+
Promise: root.Promise,
|
28
28
|
},
|
29
29
|
helpers: { }
|
30
30
|
};
|
@@ -66,6 +66,104 @@
|
|
66
66
|
var objectDisposed = 'Object has been disposed';
|
67
67
|
function checkDisposed() { if (this.isDisposed) { throw new Error(objectDisposed); } }
|
68
68
|
|
69
|
+
Rx.config.longStackSupport = false;
|
70
|
+
var hasStacks = false;
|
71
|
+
try {
|
72
|
+
throw new Error();
|
73
|
+
} catch (e) {
|
74
|
+
hasStacks = !!e.stack;
|
75
|
+
}
|
76
|
+
|
77
|
+
// All code after this point will be filtered from stack traces reported by RxJS
|
78
|
+
var rStartingLine = captureLine(), rFileName;
|
79
|
+
|
80
|
+
var STACK_JUMP_SEPARATOR = "From previous event:";
|
81
|
+
|
82
|
+
function makeStackTraceLong(error, observable) {
|
83
|
+
// If possible, transform the error stack trace by removing Node and RxJS
|
84
|
+
// cruft, then concatenating with the stack trace of `observable`.
|
85
|
+
if (hasStacks &&
|
86
|
+
observable.stack &&
|
87
|
+
typeof error === "object" &&
|
88
|
+
error !== null &&
|
89
|
+
error.stack &&
|
90
|
+
error.stack.indexOf(STACK_JUMP_SEPARATOR) === -1
|
91
|
+
) {
|
92
|
+
var stacks = [];
|
93
|
+
for (var o = observable; !!o; o = o.source) {
|
94
|
+
if (o.stack) {
|
95
|
+
stacks.unshift(o.stack);
|
96
|
+
}
|
97
|
+
}
|
98
|
+
stacks.unshift(error.stack);
|
99
|
+
|
100
|
+
var concatedStacks = stacks.join("\n" + STACK_JUMP_SEPARATOR + "\n");
|
101
|
+
error.stack = filterStackString(concatedStacks);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
function filterStackString(stackString) {
|
106
|
+
var lines = stackString.split("\n"),
|
107
|
+
desiredLines = [];
|
108
|
+
for (var i = 0, len = lines.length; i < len; i++) {
|
109
|
+
var line = lines[i];
|
110
|
+
|
111
|
+
if (!isInternalFrame(line) && !isNodeFrame(line) && line) {
|
112
|
+
desiredLines.push(line);
|
113
|
+
}
|
114
|
+
}
|
115
|
+
return desiredLines.join("\n");
|
116
|
+
}
|
117
|
+
|
118
|
+
function isInternalFrame(stackLine) {
|
119
|
+
var fileNameAndLineNumber = getFileNameAndLineNumber(stackLine);
|
120
|
+
if (!fileNameAndLineNumber) {
|
121
|
+
return false;
|
122
|
+
}
|
123
|
+
var fileName = fileNameAndLineNumber[0], lineNumber = fileNameAndLineNumber[1];
|
124
|
+
|
125
|
+
console.log(rFileName, rStartingLine, rEndingLine);
|
126
|
+
|
127
|
+
return fileName === rFileName &&
|
128
|
+
lineNumber >= rStartingLine &&
|
129
|
+
lineNumber <= rEndingLine;
|
130
|
+
}
|
131
|
+
|
132
|
+
function isNodeFrame(stackLine) {
|
133
|
+
return stackLine.indexOf("(module.js:") !== -1 ||
|
134
|
+
stackLine.indexOf("(node.js:") !== -1;
|
135
|
+
}
|
136
|
+
|
137
|
+
function captureLine() {
|
138
|
+
if (!hasStacks) { return; }
|
139
|
+
|
140
|
+
try {
|
141
|
+
throw new Error();
|
142
|
+
} catch (e) {
|
143
|
+
var lines = e.stack.split("\n");
|
144
|
+
var firstLine = lines[0].indexOf("@") > 0 ? lines[1] : lines[2];
|
145
|
+
var fileNameAndLineNumber = getFileNameAndLineNumber(firstLine);
|
146
|
+
if (!fileNameAndLineNumber) { return; }
|
147
|
+
|
148
|
+
rFileName = fileNameAndLineNumber[0];
|
149
|
+
return fileNameAndLineNumber[1];
|
150
|
+
}
|
151
|
+
}
|
152
|
+
|
153
|
+
function getFileNameAndLineNumber(stackLine) {
|
154
|
+
// Named functions: "at functionName (filename:lineNumber:columnNumber)"
|
155
|
+
var attempt1 = /at .+ \((.+):(\d+):(?:\d+)\)$/.exec(stackLine);
|
156
|
+
if (attempt1) { return [attempt1[1], Number(attempt1[2])]; }
|
157
|
+
|
158
|
+
// Anonymous functions: "at filename:lineNumber:columnNumber"
|
159
|
+
var attempt2 = /at ([^ ]+):(\d+):(?:\d+)$/.exec(stackLine);
|
160
|
+
if (attempt2) { return [attempt2[1], Number(attempt2[2])]; }
|
161
|
+
|
162
|
+
// Firefox style: "function@filename:lineNumber or @filename:lineNumber"
|
163
|
+
var attempt3 = /.*@(.+):(\d+)$/.exec(stackLine);
|
164
|
+
if (attempt3) { return [attempt3[1], Number(attempt3[2])]; }
|
165
|
+
}
|
166
|
+
|
69
167
|
// Shim in iterator support
|
70
168
|
var $iterator$ = (typeof Symbol === 'function' && Symbol.iterator) ||
|
71
169
|
'_es6shim_iterator_';
|
@@ -76,7 +174,21 @@
|
|
76
174
|
|
77
175
|
var doneEnumerator = Rx.doneEnumerator = { done: true, value: undefined };
|
78
176
|
|
79
|
-
Rx.
|
177
|
+
var isIterable = Rx.helpers.isIterable = function (o) {
|
178
|
+
return o[$iterator$] !== undefined;
|
179
|
+
}
|
180
|
+
|
181
|
+
var isArrayLike = Rx.helpers.isArrayLike = function (o) {
|
182
|
+
return o && o.length !== undefined;
|
183
|
+
}
|
184
|
+
|
185
|
+
Rx.helpers.iterator = $iterator$;
|
186
|
+
|
187
|
+
var deprecate = Rx.helpers.deprecate = function (name, alternative) {
|
188
|
+
/*if (typeof console !== "undefined" && typeof console.warn === "function") {
|
189
|
+
console.warn(name + ' is deprecated, use ' + alternative + ' instead.', new Error('').stack);
|
190
|
+
}*/
|
191
|
+
}
|
80
192
|
|
81
193
|
/** `Object#toString` result shortcuts */
|
82
194
|
var argsClass = '[object Arguments]',
|
@@ -93,15 +205,16 @@
|
|
93
205
|
var toString = Object.prototype.toString,
|
94
206
|
hasOwnProperty = Object.prototype.hasOwnProperty,
|
95
207
|
supportsArgsClass = toString.call(arguments) == argsClass, // For less <IE9 && FF<4
|
96
|
-
|
208
|
+
supportNodeClass,
|
97
209
|
errorProto = Error.prototype,
|
98
210
|
objectProto = Object.prototype,
|
211
|
+
stringProto = String.prototype,
|
99
212
|
propertyIsEnumerable = objectProto.propertyIsEnumerable;
|
100
213
|
|
101
214
|
try {
|
102
|
-
|
103
|
-
} catch(e) {
|
104
|
-
|
215
|
+
supportNodeClass = !(toString.call(document) == objectClass && !({ 'toString': 0 } + ''));
|
216
|
+
} catch (e) {
|
217
|
+
supportNodeClass = true;
|
105
218
|
}
|
106
219
|
|
107
220
|
var shadowedProps = [
|
@@ -206,7 +319,7 @@
|
|
206
319
|
return typeof value.toString != 'function' && typeof (value + '') == 'string';
|
207
320
|
}
|
208
321
|
|
209
|
-
|
322
|
+
var isArguments = function(value) {
|
210
323
|
return (value && typeof value == 'object') ? toString.call(value) == argsClass : false;
|
211
324
|
}
|
212
325
|
|
@@ -262,10 +375,10 @@
|
|
262
375
|
|
263
376
|
case numberClass:
|
264
377
|
// treat `NaN` vs. `NaN` as equal
|
265
|
-
return (a != +a)
|
266
|
-
|
378
|
+
return (a != +a) ?
|
379
|
+
b != +b :
|
267
380
|
// but treat `-0` vs. `+0` as not equal
|
268
|
-
|
381
|
+
(a == 0 ? (1 / a == 1 / b) : a == +b);
|
269
382
|
|
270
383
|
case regexpClass:
|
271
384
|
case stringClass:
|
@@ -1119,15 +1232,13 @@ if (!Array.prototype.forEach) {
|
|
1119
1232
|
|
1120
1233
|
}(Scheduler.prototype));
|
1121
1234
|
|
1122
|
-
/**
|
1123
|
-
* Gets a scheduler that schedules work immediately on the current thread.
|
1124
|
-
*/
|
1235
|
+
/** Gets a scheduler that schedules work immediately on the current thread. */
|
1125
1236
|
var immediateScheduler = Scheduler.immediate = (function () {
|
1126
1237
|
|
1127
1238
|
function scheduleNow(state, action) { return action(this, state); }
|
1128
1239
|
|
1129
1240
|
function scheduleRelative(state, dueTime, action) {
|
1130
|
-
var dt = normalizeTime(
|
1241
|
+
var dt = normalizeTime(dueTime);
|
1131
1242
|
while (dt - this.now() > 0) { }
|
1132
1243
|
return action(this, state);
|
1133
1244
|
}
|
@@ -1270,24 +1381,24 @@ if (!Array.prototype.forEach) {
|
|
1270
1381
|
oldHandler = root.onmessage;
|
1271
1382
|
// Test for async
|
1272
1383
|
root.onmessage = function () { isAsync = true; };
|
1273
|
-
root.postMessage('','*');
|
1384
|
+
root.postMessage('', '*');
|
1274
1385
|
root.onmessage = oldHandler;
|
1275
1386
|
|
1276
1387
|
return isAsync;
|
1277
1388
|
}
|
1278
1389
|
|
1279
|
-
// Use in order,
|
1280
|
-
if (typeof
|
1281
|
-
scheduleMethod = process.nextTick;
|
1282
|
-
} else if (typeof setImmediate === 'function') {
|
1390
|
+
// Use in order, setImmediate, nextTick, postMessage, MessageChannel, script readystatechanged, setTimeout
|
1391
|
+
if (typeof setImmediate === 'function') {
|
1283
1392
|
scheduleMethod = setImmediate;
|
1284
1393
|
clearMethod = clearImmediate;
|
1394
|
+
} else if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') {
|
1395
|
+
scheduleMethod = process.nextTick;
|
1285
1396
|
} else if (postMessageSupported()) {
|
1286
1397
|
var MSG_PREFIX = 'ms.rx.schedule' + Math.random(),
|
1287
1398
|
tasks = {},
|
1288
1399
|
taskId = 0;
|
1289
1400
|
|
1290
|
-
function
|
1401
|
+
var onGlobalPostMessage = function (event) {
|
1291
1402
|
// Only if we're a match to avoid any other global events
|
1292
1403
|
if (typeof event.data === 'string' && event.data.substring(0, MSG_PREFIX.length) === MSG_PREFIX) {
|
1293
1404
|
var handleId = event.data.substring(MSG_PREFIX.length),
|
@@ -1516,8 +1627,8 @@ if (!Array.prototype.forEach) {
|
|
1516
1627
|
var e;
|
1517
1628
|
try {
|
1518
1629
|
e = sources[$iterator$]();
|
1519
|
-
} catch(err) {
|
1520
|
-
observer.onError();
|
1630
|
+
} catch (err) {
|
1631
|
+
observer.onError(err);
|
1521
1632
|
return;
|
1522
1633
|
}
|
1523
1634
|
|
@@ -1558,14 +1669,14 @@ if (!Array.prototype.forEach) {
|
|
1558
1669
|
});
|
1559
1670
|
};
|
1560
1671
|
|
1561
|
-
Enumerable.prototype.
|
1672
|
+
Enumerable.prototype.catchError = function () {
|
1562
1673
|
var sources = this;
|
1563
1674
|
return new AnonymousObservable(function (observer) {
|
1564
1675
|
var e;
|
1565
1676
|
try {
|
1566
1677
|
e = sources[$iterator$]();
|
1567
|
-
} catch(err) {
|
1568
|
-
observer.onError();
|
1678
|
+
} catch (err) {
|
1679
|
+
observer.onError(err);
|
1569
1680
|
return;
|
1570
1681
|
}
|
1571
1682
|
|
@@ -1805,6 +1916,24 @@ if (!Array.prototype.forEach) {
|
|
1805
1916
|
var Observable = Rx.Observable = (function () {
|
1806
1917
|
|
1807
1918
|
function Observable(subscribe) {
|
1919
|
+
if (Rx.config.longStackSupport && hasStacks) {
|
1920
|
+
try {
|
1921
|
+
throw new Error();
|
1922
|
+
} catch (e) {
|
1923
|
+
this.stack = e.stack.substring(e.stack.indexOf("\n") + 1);
|
1924
|
+
}
|
1925
|
+
|
1926
|
+
var self = this;
|
1927
|
+
this._subscribe = function (observer) {
|
1928
|
+
observer.onError = function (err) {
|
1929
|
+
makeStackTraceLong(self, err);
|
1930
|
+
observer.onError(err);
|
1931
|
+
};
|
1932
|
+
|
1933
|
+
subscribe(observer);
|
1934
|
+
};
|
1935
|
+
}
|
1936
|
+
|
1808
1937
|
this._subscribe = subscribe;
|
1809
1938
|
}
|
1810
1939
|
|
@@ -1871,23 +2000,17 @@ if (!Array.prototype.forEach) {
|
|
1871
2000
|
|
1872
2001
|
ScheduledObserver.prototype.next = function (value) {
|
1873
2002
|
var self = this;
|
1874
|
-
this.queue.push(function () {
|
1875
|
-
self.observer.onNext(value);
|
1876
|
-
});
|
2003
|
+
this.queue.push(function () { self.observer.onNext(value); });
|
1877
2004
|
};
|
1878
2005
|
|
1879
|
-
ScheduledObserver.prototype.error = function (
|
2006
|
+
ScheduledObserver.prototype.error = function (e) {
|
1880
2007
|
var self = this;
|
1881
|
-
this.queue.push(function () {
|
1882
|
-
self.observer.onError(err);
|
1883
|
-
});
|
2008
|
+
this.queue.push(function () { self.observer.onError(e); });
|
1884
2009
|
};
|
1885
2010
|
|
1886
2011
|
ScheduledObserver.prototype.completed = function () {
|
1887
2012
|
var self = this;
|
1888
|
-
this.queue.push(function () {
|
1889
|
-
self.observer.onCompleted();
|
1890
|
-
});
|
2013
|
+
this.queue.push(function () { self.observer.onCompleted(); });
|
1891
2014
|
};
|
1892
2015
|
|
1893
2016
|
ScheduledObserver.prototype.ensureActive = function () {
|
@@ -1926,36 +2049,34 @@ if (!Array.prototype.forEach) {
|
|
1926
2049
|
}(AbstractObserver));
|
1927
2050
|
|
1928
2051
|
/**
|
1929
|
-
* Creates
|
1930
|
-
* @returns An observable sequence containing a single element with a list containing all the elements of the source sequence.
|
2052
|
+
* Creates an array from an observable sequence.
|
2053
|
+
* @returns {Observable} An observable sequence containing a single element with a list containing all the elements of the source sequence.
|
1931
2054
|
*/
|
1932
2055
|
observableProto.toArray = function () {
|
1933
|
-
var
|
2056
|
+
var source = this;
|
1934
2057
|
return new AnonymousObservable(function(observer) {
|
1935
2058
|
var arr = [];
|
1936
|
-
return
|
2059
|
+
return source.subscribe(
|
1937
2060
|
arr.push.bind(arr),
|
1938
2061
|
observer.onError.bind(observer),
|
1939
2062
|
function () {
|
1940
2063
|
observer.onNext(arr);
|
1941
2064
|
observer.onCompleted();
|
1942
2065
|
});
|
1943
|
-
});
|
2066
|
+
}, source);
|
1944
2067
|
};
|
1945
2068
|
|
1946
2069
|
/**
|
1947
2070
|
* Creates an observable sequence from a specified subscribe method implementation.
|
1948
|
-
*
|
1949
2071
|
* @example
|
1950
2072
|
* var res = Rx.Observable.create(function (observer) { return function () { } );
|
1951
2073
|
* var res = Rx.Observable.create(function (observer) { return Rx.Disposable.empty; } );
|
1952
2074
|
* var res = Rx.Observable.create(function (observer) { } );
|
1953
|
-
*
|
1954
2075
|
* @param {Function} subscribe Implementation of the resulting observable sequence's subscribe method, returning a function that will be wrapped in a Disposable.
|
1955
2076
|
* @returns {Observable} The observable sequence with the specified implementation for the Subscribe method.
|
1956
2077
|
*/
|
1957
|
-
Observable.create = Observable.createWithDisposable = function (subscribe) {
|
1958
|
-
return new AnonymousObservable(subscribe);
|
2078
|
+
Observable.create = Observable.createWithDisposable = function (subscribe, parent) {
|
2079
|
+
return new AnonymousObservable(subscribe, parent);
|
1959
2080
|
};
|
1960
2081
|
|
1961
2082
|
/**
|
@@ -1999,6 +2120,60 @@ if (!Array.prototype.forEach) {
|
|
1999
2120
|
|
2000
2121
|
var maxSafeInteger = Math.pow(2, 53) - 1;
|
2001
2122
|
|
2123
|
+
function StringIterable(str) {
|
2124
|
+
this._s = s;
|
2125
|
+
}
|
2126
|
+
|
2127
|
+
StringIterable.prototype[$iterator$] = function () {
|
2128
|
+
return new StringIterator(this._s);
|
2129
|
+
};
|
2130
|
+
|
2131
|
+
function StringIterator(str) {
|
2132
|
+
this._s = s;
|
2133
|
+
this._l = s.length;
|
2134
|
+
this._i = 0;
|
2135
|
+
}
|
2136
|
+
|
2137
|
+
StringIterator.prototype[$iterator$] = function () {
|
2138
|
+
return this;
|
2139
|
+
};
|
2140
|
+
|
2141
|
+
StringIterator.prototype.next = function () {
|
2142
|
+
if (this._i < this._l) {
|
2143
|
+
var val = this._s.charAt(this._i++);
|
2144
|
+
return { done: false, value: val };
|
2145
|
+
} else {
|
2146
|
+
return doneEnumerator;
|
2147
|
+
}
|
2148
|
+
};
|
2149
|
+
|
2150
|
+
function ArrayIterable(a) {
|
2151
|
+
this._a = a;
|
2152
|
+
}
|
2153
|
+
|
2154
|
+
ArrayIterable.prototype[$iterator$] = function () {
|
2155
|
+
return new ArrayIterator(this._a);
|
2156
|
+
};
|
2157
|
+
|
2158
|
+
function ArrayIterator(a) {
|
2159
|
+
this._a = a;
|
2160
|
+
this._l = toLength(a);
|
2161
|
+
this._i = 0;
|
2162
|
+
}
|
2163
|
+
|
2164
|
+
ArrayIterator.prototype[$iterator$] = function () {
|
2165
|
+
return this;
|
2166
|
+
};
|
2167
|
+
|
2168
|
+
ArrayIterator.prototype.next = function () {
|
2169
|
+
if (this._i < this._l) {
|
2170
|
+
var val = this._a[this._i++];
|
2171
|
+
return { done: false, value: val };
|
2172
|
+
} else {
|
2173
|
+
return doneEnumerator;
|
2174
|
+
}
|
2175
|
+
};
|
2176
|
+
|
2002
2177
|
function numberIsFinite(value) {
|
2003
2178
|
return typeof value === 'number' && root.isFinite(value);
|
2004
2179
|
}
|
@@ -2007,8 +2182,18 @@ if (!Array.prototype.forEach) {
|
|
2007
2182
|
return n !== n;
|
2008
2183
|
}
|
2009
2184
|
|
2010
|
-
function
|
2011
|
-
|
2185
|
+
function getIterable(o) {
|
2186
|
+
var i = o[$iterator$], it;
|
2187
|
+
if (!i && typeof o === 'string') {
|
2188
|
+
it = new StringIterable(o);
|
2189
|
+
return it[$iterator$]();
|
2190
|
+
}
|
2191
|
+
if (!i && o.length !== undefined) {
|
2192
|
+
it = new ArrayIterable(o);
|
2193
|
+
return it[$iterator$]();
|
2194
|
+
}
|
2195
|
+
if (!i) { throw new TypeError('Object is not iterable'); }
|
2196
|
+
return o[$iterator$]();
|
2012
2197
|
}
|
2013
2198
|
|
2014
2199
|
function sign(value) {
|
@@ -2028,10 +2213,6 @@ if (!Array.prototype.forEach) {
|
|
2028
2213
|
return len;
|
2029
2214
|
}
|
2030
2215
|
|
2031
|
-
function isCallable(f) {
|
2032
|
-
return Object.prototype.toString.call(f) === '[object Function]' && typeof f === 'function';
|
2033
|
-
}
|
2034
|
-
|
2035
2216
|
/**
|
2036
2217
|
* This method creates a new Observable sequence from an array-like or iterable object.
|
2037
2218
|
* @param {Any} arrayLike An array-like or iterable object to convert to an Observable sequence.
|
@@ -2043,66 +2224,52 @@ if (!Array.prototype.forEach) {
|
|
2043
2224
|
if (iterable == null) {
|
2044
2225
|
throw new Error('iterable cannot be null.')
|
2045
2226
|
}
|
2046
|
-
if (mapFn && !
|
2227
|
+
if (mapFn && !isFunction(mapFn)) {
|
2047
2228
|
throw new Error('mapFn when provided must be a function');
|
2048
2229
|
}
|
2049
2230
|
isScheduler(scheduler) || (scheduler = currentThreadScheduler);
|
2231
|
+
var list = Object(iterable), it = getIterable(list);
|
2050
2232
|
return new AnonymousObservable(function (observer) {
|
2051
|
-
var
|
2052
|
-
objIsIterable = isIterable(list),
|
2053
|
-
len = objIsIterable ? 0 : toLength(list),
|
2054
|
-
it = objIsIterable ? list[$iterator$]() : null,
|
2055
|
-
i = 0;
|
2233
|
+
var i = 0;
|
2056
2234
|
return scheduler.scheduleRecursive(function (self) {
|
2057
|
-
|
2058
|
-
|
2059
|
-
|
2060
|
-
|
2061
|
-
|
2062
|
-
|
2063
|
-
|
2064
|
-
|
2065
|
-
|
2066
|
-
|
2067
|
-
|
2068
|
-
observer.onCompleted();
|
2069
|
-
return;
|
2070
|
-
}
|
2235
|
+
var next;
|
2236
|
+
try {
|
2237
|
+
next = it.next();
|
2238
|
+
} catch (e) {
|
2239
|
+
observer.onError(e);
|
2240
|
+
return;
|
2241
|
+
}
|
2242
|
+
if (next.done) {
|
2243
|
+
observer.onCompleted();
|
2244
|
+
return;
|
2245
|
+
}
|
2071
2246
|
|
2072
|
-
|
2073
|
-
} else {
|
2074
|
-
result = !!list.charAt ? list.charAt(i) : list[i];
|
2075
|
-
}
|
2247
|
+
var result = next.value;
|
2076
2248
|
|
2077
|
-
|
2078
|
-
|
2079
|
-
|
2080
|
-
|
2081
|
-
|
2082
|
-
|
2083
|
-
}
|
2249
|
+
if (mapFn && isFunction(mapFn)) {
|
2250
|
+
try {
|
2251
|
+
result = mapFn.call(thisArg, result, i);
|
2252
|
+
} catch (e) {
|
2253
|
+
observer.onError(e);
|
2254
|
+
return;
|
2084
2255
|
}
|
2085
|
-
|
2086
|
-
observer.onNext(result);
|
2087
|
-
i++;
|
2088
|
-
self();
|
2089
|
-
} else {
|
2090
|
-
observer.onCompleted();
|
2091
2256
|
}
|
2257
|
+
|
2258
|
+
observer.onNext(result);
|
2259
|
+
i++;
|
2260
|
+
self();
|
2092
2261
|
});
|
2093
2262
|
});
|
2094
2263
|
};
|
2095
2264
|
|
2096
2265
|
/**
|
2097
2266
|
* Converts an array to an observable sequence, using an optional scheduler to enumerate the array.
|
2098
|
-
*
|
2099
|
-
* @example
|
2100
|
-
* var res = Rx.Observable.fromArray([1,2,3]);
|
2101
|
-
* var res = Rx.Observable.fromArray([1,2,3], Rx.Scheduler.timeout);
|
2267
|
+
* @deprecated use Observable.from or Observable.of
|
2102
2268
|
* @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on.
|
2103
2269
|
* @returns {Observable} The observable sequence whose elements are pulled from the given enumerable sequence.
|
2104
2270
|
*/
|
2105
2271
|
var observableFromArray = Observable.fromArray = function (array, scheduler) {
|
2272
|
+
deprecate('fromArray', 'from');
|
2106
2273
|
isScheduler(scheduler) || (scheduler = currentThreadScheduler);
|
2107
2274
|
return new AnonymousObservable(function (observer) {
|
2108
2275
|
var count = 0, len = array.length;
|
@@ -2127,29 +2294,36 @@ if (!Array.prototype.forEach) {
|
|
2127
2294
|
});
|
2128
2295
|
};
|
2129
2296
|
|
2297
|
+
function observableOf (scheduler, array) {
|
2298
|
+
isScheduler(scheduler) || (scheduler = currentThreadScheduler);
|
2299
|
+
return new AnonymousObservable(function (observer) {
|
2300
|
+
var count = 0, len = array.length;
|
2301
|
+
return scheduler.scheduleRecursive(function (self) {
|
2302
|
+
if (count < len) {
|
2303
|
+
observer.onNext(array[count++]);
|
2304
|
+
self();
|
2305
|
+
} else {
|
2306
|
+
observer.onCompleted();
|
2307
|
+
}
|
2308
|
+
});
|
2309
|
+
});
|
2310
|
+
}
|
2311
|
+
|
2130
2312
|
/**
|
2131
2313
|
* This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.
|
2132
|
-
* @example
|
2133
|
-
* var res = Rx.Observable.of(1,2,3);
|
2134
2314
|
* @returns {Observable} The observable sequence whose elements are pulled from the given arguments.
|
2135
2315
|
*/
|
2136
2316
|
Observable.of = function () {
|
2137
|
-
|
2138
|
-
for(var i = 0; i < len; i++) { args[i] = arguments[i]; }
|
2139
|
-
return observableFromArray(args);
|
2317
|
+
return observableOf(null, arguments);
|
2140
2318
|
};
|
2141
2319
|
|
2142
2320
|
/**
|
2143
2321
|
* This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.
|
2144
|
-
* @example
|
2145
|
-
* var res = Rx.Observable.of(1,2,3);
|
2146
2322
|
* @param {Scheduler} scheduler A scheduler to use for scheduling the arguments.
|
2147
2323
|
* @returns {Observable} The observable sequence whose elements are pulled from the given arguments.
|
2148
2324
|
*/
|
2149
|
-
|
2150
|
-
|
2151
|
-
for(var i = 0; i < len; i++) { args[i] = arguments[i + 1]; }
|
2152
|
-
return observableFromArray(args, scheduler);
|
2325
|
+
Observable.ofWithScheduler = function (scheduler) {
|
2326
|
+
return observableOf(scheduler, slice.call(arguments, 1));
|
2153
2327
|
};
|
2154
2328
|
|
2155
2329
|
/**
|
@@ -2206,7 +2380,7 @@ if (!Array.prototype.forEach) {
|
|
2206
2380
|
* @param {Scheduler} scheduler Scheduler to send the single element on. If not specified, defaults to Scheduler.immediate.
|
2207
2381
|
* @returns {Observable} An observable sequence containing the single specified element.
|
2208
2382
|
*/
|
2209
|
-
var observableReturn = Observable['return'] = Observable.
|
2383
|
+
var observableReturn = Observable['return'] = Observable.just = function (value, scheduler) {
|
2210
2384
|
isScheduler(scheduler) || (scheduler = immediateScheduler);
|
2211
2385
|
return new AnonymousObservable(function (observer) {
|
2212
2386
|
return scheduler.schedule(function () {
|
@@ -2216,6 +2390,12 @@ if (!Array.prototype.forEach) {
|
|
2216
2390
|
});
|
2217
2391
|
};
|
2218
2392
|
|
2393
|
+
/** @deprecated use return or just */
|
2394
|
+
Observable.returnValue = function () {
|
2395
|
+
deprecate('returnValue', 'return or just');
|
2396
|
+
return observableReturn.apply(null, arguments);
|
2397
|
+
};
|
2398
|
+
|
2219
2399
|
/**
|
2220
2400
|
* Returns an observable sequence that terminates with an exception, using the specified scheduler to send out the single onError message.
|
2221
2401
|
* There is an alias to this method called 'throwError' for browsers <IE9.
|
@@ -2252,7 +2432,7 @@ if (!Array.prototype.forEach) {
|
|
2252
2432
|
}, observer.onCompleted.bind(observer)));
|
2253
2433
|
|
2254
2434
|
return subscription;
|
2255
|
-
});
|
2435
|
+
}, source);
|
2256
2436
|
}
|
2257
2437
|
|
2258
2438
|
/**
|
@@ -2263,19 +2443,35 @@ if (!Array.prototype.forEach) {
|
|
2263
2443
|
* @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.
|
2264
2444
|
* @returns {Observable} An observable sequence containing the first sequence's elements, followed by the elements of the handler sequence in case an exception occurred.
|
2265
2445
|
*/
|
2266
|
-
observableProto['catch'] = observableProto.catchError =
|
2446
|
+
observableProto['catch'] = observableProto.catchError = function (handlerOrSecond) {
|
2267
2447
|
return typeof handlerOrSecond === 'function' ?
|
2268
2448
|
observableCatchHandler(this, handlerOrSecond) :
|
2269
2449
|
observableCatch([this, handlerOrSecond]);
|
2270
2450
|
};
|
2271
2451
|
|
2452
|
+
/**
|
2453
|
+
* @deprecated use #catch or #catchError instead.
|
2454
|
+
*/
|
2455
|
+
observableProto.catchException = function (handlerOrSecond) {
|
2456
|
+
deprecate('catchException', 'catch or catchError');
|
2457
|
+
return this.catchError(handlerOrSecond);
|
2458
|
+
};
|
2459
|
+
|
2272
2460
|
/**
|
2273
2461
|
* Continues an observable sequence that is terminated by an exception with the next observable sequence.
|
2274
2462
|
* @param {Array | Arguments} args Arguments or an array to use as the next sequence if an error occurs.
|
2275
2463
|
* @returns {Observable} An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.
|
2276
2464
|
*/
|
2277
|
-
var observableCatch = Observable.
|
2278
|
-
return enumerableOf(argsOrArray(arguments, 0)).
|
2465
|
+
var observableCatch = Observable.catchError = Observable['catch'] = function () {
|
2466
|
+
return enumerableOf(argsOrArray(arguments, 0)).catchError();
|
2467
|
+
};
|
2468
|
+
|
2469
|
+
/**
|
2470
|
+
* @deprecated use #catch or #catchError instead.
|
2471
|
+
*/
|
2472
|
+
Observable.catchException = function () {
|
2473
|
+
deprecate('catchException', 'catch or catchError');
|
2474
|
+
return observableCatch.apply(null, arguments);
|
2279
2475
|
};
|
2280
2476
|
|
2281
2477
|
/**
|
@@ -2359,7 +2555,7 @@ if (!Array.prototype.forEach) {
|
|
2359
2555
|
}
|
2360
2556
|
|
2361
2557
|
return new CompositeDisposable(subscriptions);
|
2362
|
-
});
|
2558
|
+
}, this);
|
2363
2559
|
};
|
2364
2560
|
|
2365
2561
|
/**
|
@@ -2385,13 +2581,19 @@ if (!Array.prototype.forEach) {
|
|
2385
2581
|
return enumerableOf(argsOrArray(arguments, 0)).concat();
|
2386
2582
|
};
|
2387
2583
|
|
2388
|
-
|
2389
|
-
|
2390
|
-
|
2391
|
-
|
2392
|
-
|
2393
|
-
|
2394
|
-
|
2584
|
+
/**
|
2585
|
+
* Concatenates an observable sequence of observable sequences.
|
2586
|
+
* @returns {Observable} An observable sequence that contains the elements of each observed inner sequence, in sequential order.
|
2587
|
+
*/
|
2588
|
+
observableProto.concatAll = function () {
|
2589
|
+
return this.merge(1);
|
2590
|
+
};
|
2591
|
+
|
2592
|
+
/** @deprecated Use `concatAll` instead. */
|
2593
|
+
observableProto.concatObservable = function () {
|
2594
|
+
deprecate('concatObservable', 'concatAll');
|
2595
|
+
return this.merge(1);
|
2596
|
+
};
|
2395
2597
|
|
2396
2598
|
/**
|
2397
2599
|
* Merges an observable sequence of observable sequences into an observable sequence, limiting the number of concurrent subscriptions to inner sequences.
|
@@ -2438,43 +2640,37 @@ if (!Array.prototype.forEach) {
|
|
2438
2640
|
activeCount === 0 && observer.onCompleted();
|
2439
2641
|
}));
|
2440
2642
|
return group;
|
2441
|
-
});
|
2643
|
+
}, sources);
|
2442
2644
|
};
|
2443
2645
|
|
2444
|
-
|
2445
|
-
|
2446
|
-
|
2447
|
-
|
2448
|
-
|
2449
|
-
|
2450
|
-
|
2451
|
-
|
2452
|
-
|
2453
|
-
|
2454
|
-
|
2455
|
-
|
2456
|
-
|
2457
|
-
|
2458
|
-
|
2459
|
-
|
2460
|
-
|
2461
|
-
|
2462
|
-
|
2463
|
-
|
2464
|
-
|
2465
|
-
|
2466
|
-
}
|
2467
|
-
if (Array.isArray(sources[0])) {
|
2468
|
-
sources = sources[0];
|
2469
|
-
}
|
2470
|
-
return observableFromArray(sources, scheduler).mergeObservable();
|
2471
|
-
};
|
2646
|
+
/**
|
2647
|
+
* Merges all the observable sequences into a single observable sequence.
|
2648
|
+
* The scheduler is optional and if not specified, the immediate scheduler is used.
|
2649
|
+
* @returns {Observable} The observable sequence that merges the elements of the observable sequences.
|
2650
|
+
*/
|
2651
|
+
var observableMerge = Observable.merge = function () {
|
2652
|
+
var scheduler, sources;
|
2653
|
+
if (!arguments[0]) {
|
2654
|
+
scheduler = immediateScheduler;
|
2655
|
+
sources = slice.call(arguments, 1);
|
2656
|
+
} else if (isScheduler(arguments[0])) {
|
2657
|
+
scheduler = arguments[0];
|
2658
|
+
sources = slice.call(arguments, 1);
|
2659
|
+
} else {
|
2660
|
+
scheduler = immediateScheduler;
|
2661
|
+
sources = slice.call(arguments, 0);
|
2662
|
+
}
|
2663
|
+
if (Array.isArray(sources[0])) {
|
2664
|
+
sources = sources[0];
|
2665
|
+
}
|
2666
|
+
return observableOf(scheduler, sources).mergeAll();
|
2667
|
+
};
|
2472
2668
|
|
2473
2669
|
/**
|
2474
2670
|
* Merges an observable sequence of observable sequences into an observable sequence.
|
2475
2671
|
* @returns {Observable} The observable sequence that merges the elements of the inner sequences.
|
2476
2672
|
*/
|
2477
|
-
observableProto.
|
2673
|
+
observableProto.mergeAll = function () {
|
2478
2674
|
var sources = this;
|
2479
2675
|
return new AnonymousObservable(function (observer) {
|
2480
2676
|
var group = new CompositeDisposable(),
|
@@ -2498,7 +2694,15 @@ if (!Array.prototype.forEach) {
|
|
2498
2694
|
group.length === 1 && observer.onCompleted();
|
2499
2695
|
}));
|
2500
2696
|
return group;
|
2501
|
-
});
|
2697
|
+
}, sources);
|
2698
|
+
};
|
2699
|
+
|
2700
|
+
/**
|
2701
|
+
* @deprecated use #mergeAll instead.
|
2702
|
+
*/
|
2703
|
+
observableProto.mergeObservable = function () {
|
2704
|
+
deprecate('mergeObservable', 'mergeAll');
|
2705
|
+
return this.mergeAll.apply(this, arguments);
|
2502
2706
|
};
|
2503
2707
|
|
2504
2708
|
/**
|
@@ -2528,7 +2732,7 @@ if (!Array.prototype.forEach) {
|
|
2528
2732
|
}));
|
2529
2733
|
|
2530
2734
|
return disposables;
|
2531
|
-
});
|
2735
|
+
}, source);
|
2532
2736
|
};
|
2533
2737
|
|
2534
2738
|
/**
|
@@ -2567,7 +2771,7 @@ if (!Array.prototype.forEach) {
|
|
2567
2771
|
!hasLatest && observer.onCompleted();
|
2568
2772
|
});
|
2569
2773
|
return new CompositeDisposable(subscription, innerSubscription);
|
2570
|
-
});
|
2774
|
+
}, sources);
|
2571
2775
|
};
|
2572
2776
|
|
2573
2777
|
/**
|
@@ -2583,7 +2787,7 @@ if (!Array.prototype.forEach) {
|
|
2583
2787
|
source.subscribe(observer),
|
2584
2788
|
other.subscribe(observer.onCompleted.bind(observer), observer.onError.bind(observer), noop)
|
2585
2789
|
);
|
2586
|
-
});
|
2790
|
+
}, source);
|
2587
2791
|
};
|
2588
2792
|
|
2589
2793
|
function zipArray(second, resultSelector) {
|
@@ -2604,7 +2808,7 @@ if (!Array.prototype.forEach) {
|
|
2604
2808
|
observer.onCompleted();
|
2605
2809
|
}
|
2606
2810
|
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
2607
|
-
});
|
2811
|
+
}, first);
|
2608
2812
|
}
|
2609
2813
|
|
2610
2814
|
/**
|
@@ -2666,7 +2870,7 @@ if (!Array.prototype.forEach) {
|
|
2666
2870
|
}
|
2667
2871
|
|
2668
2872
|
return new CompositeDisposable(subscriptions);
|
2669
|
-
});
|
2873
|
+
}, parent);
|
2670
2874
|
};
|
2671
2875
|
|
2672
2876
|
/**
|
@@ -2736,63 +2940,61 @@ if (!Array.prototype.forEach) {
|
|
2736
2940
|
* @returns {Observable} An observable sequence that hides the identity of the source sequence.
|
2737
2941
|
*/
|
2738
2942
|
observableProto.asObservable = function () {
|
2739
|
-
return new AnonymousObservable(this.subscribe.bind(this));
|
2943
|
+
return new AnonymousObservable(this.subscribe.bind(this), this);
|
2740
2944
|
};
|
2741
2945
|
|
2742
|
-
|
2743
|
-
|
2744
|
-
|
2745
|
-
|
2746
|
-
|
2747
|
-
|
2748
|
-
|
2749
|
-
|
2750
|
-
|
2751
|
-
|
2752
|
-
});
|
2753
|
-
};
|
2946
|
+
/**
|
2947
|
+
* Dematerializes the explicit notification values of an observable sequence as implicit notifications.
|
2948
|
+
* @returns {Observable} An observable sequence exhibiting the behavior corresponding to the source sequence's notification values.
|
2949
|
+
*/
|
2950
|
+
observableProto.dematerialize = function () {
|
2951
|
+
var source = this;
|
2952
|
+
return new AnonymousObservable(function (observer) {
|
2953
|
+
return source.subscribe(function (x) { return x.accept(observer); }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
2954
|
+
}, this);
|
2955
|
+
};
|
2754
2956
|
|
2755
|
-
|
2756
|
-
|
2757
|
-
|
2758
|
-
|
2759
|
-
|
2760
|
-
|
2761
|
-
|
2762
|
-
|
2763
|
-
|
2764
|
-
|
2765
|
-
|
2766
|
-
|
2767
|
-
|
2768
|
-
|
2769
|
-
|
2770
|
-
|
2771
|
-
|
2772
|
-
|
2773
|
-
|
2774
|
-
|
2775
|
-
|
2776
|
-
|
2777
|
-
|
2778
|
-
|
2779
|
-
|
2780
|
-
|
2781
|
-
|
2782
|
-
|
2783
|
-
|
2784
|
-
|
2785
|
-
|
2786
|
-
|
2787
|
-
|
2788
|
-
|
2789
|
-
|
2790
|
-
|
2791
|
-
|
2792
|
-
|
2793
|
-
|
2794
|
-
|
2795
|
-
|
2957
|
+
/**
|
2958
|
+
* Returns an observable sequence that contains only distinct contiguous elements according to the keySelector and the comparer.
|
2959
|
+
*
|
2960
|
+
* var obs = observable.distinctUntilChanged();
|
2961
|
+
* var obs = observable.distinctUntilChanged(function (x) { return x.id; });
|
2962
|
+
* var obs = observable.distinctUntilChanged(function (x) { return x.id; }, function (x, y) { return x === y; });
|
2963
|
+
*
|
2964
|
+
* @param {Function} [keySelector] A function to compute the comparison key for each element. If not provided, it projects the value.
|
2965
|
+
* @param {Function} [comparer] Equality comparer for computed key values. If not provided, defaults to an equality comparer function.
|
2966
|
+
* @returns {Observable} An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence.
|
2967
|
+
*/
|
2968
|
+
observableProto.distinctUntilChanged = function (keySelector, comparer) {
|
2969
|
+
var source = this;
|
2970
|
+
keySelector || (keySelector = identity);
|
2971
|
+
comparer || (comparer = defaultComparer);
|
2972
|
+
return new AnonymousObservable(function (observer) {
|
2973
|
+
var hasCurrentKey = false, currentKey;
|
2974
|
+
return source.subscribe(function (value) {
|
2975
|
+
var comparerEquals = false, key;
|
2976
|
+
try {
|
2977
|
+
key = keySelector(value);
|
2978
|
+
} catch (e) {
|
2979
|
+
observer.onError(e);
|
2980
|
+
return;
|
2981
|
+
}
|
2982
|
+
if (hasCurrentKey) {
|
2983
|
+
try {
|
2984
|
+
comparerEquals = comparer(currentKey, key);
|
2985
|
+
} catch (e) {
|
2986
|
+
observer.onError(e);
|
2987
|
+
return;
|
2988
|
+
}
|
2989
|
+
}
|
2990
|
+
if (!hasCurrentKey || !comparerEquals) {
|
2991
|
+
hasCurrentKey = true;
|
2992
|
+
currentKey = key;
|
2993
|
+
observer.onNext(value);
|
2994
|
+
}
|
2995
|
+
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
2996
|
+
}, this);
|
2997
|
+
};
|
2796
2998
|
|
2797
2999
|
/**
|
2798
3000
|
* Invokes an action for each element in the observable sequence and invokes an action upon graceful or exceptional termination of the observable sequence.
|
@@ -2802,7 +3004,7 @@ if (!Array.prototype.forEach) {
|
|
2802
3004
|
* @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.
|
2803
3005
|
* @returns {Observable} The source sequence with the side-effecting behavior applied.
|
2804
3006
|
*/
|
2805
|
-
observableProto['do'] = observableProto.
|
3007
|
+
observableProto['do'] = observableProto.tap = function (observerOrOnNext, onError, onCompleted) {
|
2806
3008
|
var source = this, onNextFunc;
|
2807
3009
|
if (typeof observerOrOnNext === 'function') {
|
2808
3010
|
onNextFunc = observerOrOnNext;
|
@@ -2838,7 +3040,13 @@ if (!Array.prototype.forEach) {
|
|
2838
3040
|
}
|
2839
3041
|
observer.onCompleted();
|
2840
3042
|
});
|
2841
|
-
});
|
3043
|
+
}, this);
|
3044
|
+
};
|
3045
|
+
|
3046
|
+
/** @deprecated use #do or #tap instead. */
|
3047
|
+
observableProto.doAction = function () {
|
3048
|
+
deprecate('doAction', 'do or tap');
|
3049
|
+
return this.tap.apply(this, arguments);
|
2842
3050
|
};
|
2843
3051
|
|
2844
3052
|
/**
|
@@ -2876,13 +3084,10 @@ if (!Array.prototype.forEach) {
|
|
2876
3084
|
|
2877
3085
|
/**
|
2878
3086
|
* Invokes a specified action after the source observable sequence terminates gracefully or exceptionally.
|
2879
|
-
*
|
2880
|
-
* @example
|
2881
|
-
* var res = observable.finallyAction(function () { console.log('sequence ended'; });
|
2882
3087
|
* @param {Function} finallyAction Action to invoke after the source observable sequence terminates.
|
2883
3088
|
* @returns {Observable} Source sequence with the action-invoking termination behavior applied.
|
2884
3089
|
*/
|
2885
|
-
observableProto['finally'] = observableProto.
|
3090
|
+
observableProto['finally'] = observableProto.ensure = function (action) {
|
2886
3091
|
var source = this;
|
2887
3092
|
return new AnonymousObservable(function (observer) {
|
2888
3093
|
var subscription;
|
@@ -2901,7 +3106,15 @@ if (!Array.prototype.forEach) {
|
|
2901
3106
|
action();
|
2902
3107
|
}
|
2903
3108
|
});
|
2904
|
-
});
|
3109
|
+
}, this);
|
3110
|
+
};
|
3111
|
+
|
3112
|
+
/**
|
3113
|
+
* @deprecated use #finally or #ensure instead.
|
3114
|
+
*/
|
3115
|
+
observableProto.finallyAction = function (action) {
|
3116
|
+
deprecate('finallyAction', 'finally or ensure');
|
3117
|
+
return this.ensure(action);
|
2905
3118
|
};
|
2906
3119
|
|
2907
3120
|
/**
|
@@ -2912,7 +3125,7 @@ if (!Array.prototype.forEach) {
|
|
2912
3125
|
var source = this;
|
2913
3126
|
return new AnonymousObservable(function (observer) {
|
2914
3127
|
return source.subscribe(noop, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
2915
|
-
});
|
3128
|
+
}, source);
|
2916
3129
|
};
|
2917
3130
|
|
2918
3131
|
/**
|
@@ -2931,21 +3144,17 @@ if (!Array.prototype.forEach) {
|
|
2931
3144
|
observer.onNext(notificationCreateOnCompleted());
|
2932
3145
|
observer.onCompleted();
|
2933
3146
|
});
|
2934
|
-
});
|
3147
|
+
}, source);
|
2935
3148
|
};
|
2936
3149
|
|
2937
|
-
|
2938
|
-
|
2939
|
-
|
2940
|
-
|
2941
|
-
|
2942
|
-
|
2943
|
-
|
2944
|
-
|
2945
|
-
*/
|
2946
|
-
observableProto.repeat = function (repeatCount) {
|
2947
|
-
return enumerableRepeat(this, repeatCount).concat();
|
2948
|
-
};
|
3150
|
+
/**
|
3151
|
+
* Repeats the observable sequence a specified number of times. If the repeat count is not specified, the sequence repeats indefinitely.
|
3152
|
+
* @param {Number} [repeatCount] Number of times to repeat the sequence. If not provided, repeats the sequence indefinitely.
|
3153
|
+
* @returns {Observable} The observable sequence producing the elements of the given sequence repeatedly.
|
3154
|
+
*/
|
3155
|
+
observableProto.repeat = function (repeatCount) {
|
3156
|
+
return enumerableRepeat(this, repeatCount).concat();
|
3157
|
+
};
|
2949
3158
|
|
2950
3159
|
/**
|
2951
3160
|
* 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.
|
@@ -2958,7 +3167,7 @@ if (!Array.prototype.forEach) {
|
|
2958
3167
|
* @returns {Observable} An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.
|
2959
3168
|
*/
|
2960
3169
|
observableProto.retry = function (retryCount) {
|
2961
|
-
return enumerableRepeat(this, retryCount).
|
3170
|
+
return enumerableRepeat(this, retryCount).catchError();
|
2962
3171
|
};
|
2963
3172
|
|
2964
3173
|
/**
|
@@ -3005,7 +3214,7 @@ if (!Array.prototype.forEach) {
|
|
3005
3214
|
observer.onCompleted();
|
3006
3215
|
}
|
3007
3216
|
);
|
3008
|
-
});
|
3217
|
+
}, source);
|
3009
3218
|
};
|
3010
3219
|
|
3011
3220
|
/**
|
@@ -3024,7 +3233,7 @@ if (!Array.prototype.forEach) {
|
|
3024
3233
|
q.push(x);
|
3025
3234
|
q.length > count && observer.onNext(q.shift());
|
3026
3235
|
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
3027
|
-
});
|
3236
|
+
}, source);
|
3028
3237
|
};
|
3029
3238
|
|
3030
3239
|
/**
|
@@ -3063,17 +3272,17 @@ if (!Array.prototype.forEach) {
|
|
3063
3272
|
q.push(x);
|
3064
3273
|
q.length > count && q.shift();
|
3065
3274
|
}, observer.onError.bind(observer), function () {
|
3066
|
-
while(q.length > 0) { observer.onNext(q.shift()); }
|
3275
|
+
while (q.length > 0) { observer.onNext(q.shift()); }
|
3067
3276
|
observer.onCompleted();
|
3068
3277
|
});
|
3069
|
-
});
|
3278
|
+
}, source);
|
3070
3279
|
};
|
3071
3280
|
|
3072
3281
|
function concatMap(source, selector, thisArg) {
|
3073
3282
|
return source.map(function (x, i) {
|
3074
3283
|
var result = selector.call(thisArg, x, i, source);
|
3075
3284
|
isPromise(result) && (result = observableFromPromise(result));
|
3076
|
-
(
|
3285
|
+
(isArrayLike(result) || isIterable(result)) && (result = observableFrom(result));
|
3077
3286
|
return result;
|
3078
3287
|
}).concatAll();
|
3079
3288
|
}
|
@@ -3098,43 +3307,44 @@ if (!Array.prototype.forEach) {
|
|
3098
3307
|
* @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.
|
3099
3308
|
*/
|
3100
3309
|
observableProto.selectConcat = observableProto.concatMap = function (selector, resultSelector, thisArg) {
|
3101
|
-
if (
|
3310
|
+
if (isFunction(selector) && isFunction(resultSelector)) {
|
3102
3311
|
return this.concatMap(function (x, i) {
|
3103
3312
|
var selectorResult = selector(x, i);
|
3104
3313
|
isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult));
|
3105
|
-
(
|
3314
|
+
(isArrayLike(selectorResult) || isIterable(selectorResult)) && (selectorResult = observableFrom(selectorResult));
|
3106
3315
|
|
3107
3316
|
return selectorResult.map(function (y, i2) {
|
3108
3317
|
return resultSelector(x, y, i, i2);
|
3109
3318
|
});
|
3110
3319
|
});
|
3111
3320
|
}
|
3112
|
-
return
|
3321
|
+
return isFunction(selector) ?
|
3113
3322
|
concatMap(this, selector, thisArg) :
|
3114
3323
|
concatMap(this, function () { return selector; });
|
3115
3324
|
};
|
3116
3325
|
|
3117
3326
|
/**
|
3118
|
-
*
|
3327
|
+
* Projects each element of an observable sequence into a new form by incorporating the element's index.
|
3119
3328
|
* @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.
|
3120
3329
|
* @param {Any} [thisArg] Object to use as this when executing callback.
|
3121
3330
|
* @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source.
|
3122
3331
|
*/
|
3123
3332
|
observableProto.select = observableProto.map = function (selector, thisArg) {
|
3124
|
-
var
|
3333
|
+
var selectorFn = isFunction(selector) ? selector : function () { return selector; },
|
3334
|
+
source = this;
|
3125
3335
|
return new AnonymousObservable(function (observer) {
|
3126
3336
|
var count = 0;
|
3127
|
-
return
|
3337
|
+
return source.subscribe(function (value) {
|
3128
3338
|
var result;
|
3129
3339
|
try {
|
3130
|
-
result =
|
3340
|
+
result = selectorFn.call(thisArg, value, count++, source);
|
3131
3341
|
} catch (e) {
|
3132
3342
|
observer.onError(e);
|
3133
3343
|
return;
|
3134
3344
|
}
|
3135
3345
|
observer.onNext(result);
|
3136
3346
|
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
3137
|
-
});
|
3347
|
+
}, source);
|
3138
3348
|
};
|
3139
3349
|
|
3140
3350
|
/**
|
@@ -3150,9 +3360,9 @@ if (!Array.prototype.forEach) {
|
|
3150
3360
|
return source.map(function (x, i) {
|
3151
3361
|
var result = selector.call(thisArg, x, i, source);
|
3152
3362
|
isPromise(result) && (result = observableFromPromise(result));
|
3153
|
-
(
|
3363
|
+
(isArrayLike(result) || isIterable(result)) && (result = observableFrom(result));
|
3154
3364
|
return result;
|
3155
|
-
}).
|
3365
|
+
}).mergeAll();
|
3156
3366
|
}
|
3157
3367
|
|
3158
3368
|
/**
|
@@ -3175,18 +3385,18 @@ if (!Array.prototype.forEach) {
|
|
3175
3385
|
* @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.
|
3176
3386
|
*/
|
3177
3387
|
observableProto.selectMany = observableProto.flatMap = function (selector, resultSelector, thisArg) {
|
3178
|
-
if (
|
3388
|
+
if (isFunction(selector) && isFunction(resultSelector)) {
|
3179
3389
|
return this.flatMap(function (x, i) {
|
3180
3390
|
var selectorResult = selector(x, i);
|
3181
3391
|
isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult));
|
3182
|
-
(
|
3392
|
+
(isArrayLike(selectorResult) || isIterable(selectorResult)) && (selectorResult = observableFrom(selectorResult));
|
3183
3393
|
|
3184
3394
|
return selectorResult.map(function (y, i2) {
|
3185
3395
|
return resultSelector(x, y, i, i2);
|
3186
3396
|
});
|
3187
3397
|
}, thisArg);
|
3188
3398
|
}
|
3189
|
-
return
|
3399
|
+
return isFunction(selector) ?
|
3190
3400
|
flatMap(this, selector, thisArg) :
|
3191
3401
|
flatMap(this, function () { return selector; });
|
3192
3402
|
};
|
@@ -3209,18 +3419,18 @@ if (!Array.prototype.forEach) {
|
|
3209
3419
|
* @returns {Observable} An observable sequence that contains the elements that occur after the specified index in the input sequence.
|
3210
3420
|
*/
|
3211
3421
|
observableProto.skip = function (count) {
|
3212
|
-
|
3213
|
-
|
3214
|
-
|
3215
|
-
|
3216
|
-
|
3217
|
-
|
3218
|
-
|
3219
|
-
|
3220
|
-
|
3221
|
-
|
3222
|
-
|
3223
|
-
|
3422
|
+
if (count < 0) { throw new Error(argumentOutOfRange); }
|
3423
|
+
var source = this;
|
3424
|
+
return new AnonymousObservable(function (observer) {
|
3425
|
+
var remaining = count;
|
3426
|
+
return source.subscribe(function (x) {
|
3427
|
+
if (remaining <= 0) {
|
3428
|
+
observer.onNext(x);
|
3429
|
+
} else {
|
3430
|
+
remaining--;
|
3431
|
+
}
|
3432
|
+
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
3433
|
+
}, source);
|
3224
3434
|
};
|
3225
3435
|
|
3226
3436
|
/**
|
@@ -3248,7 +3458,7 @@ if (!Array.prototype.forEach) {
|
|
3248
3458
|
}
|
3249
3459
|
running && observer.onNext(x);
|
3250
3460
|
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
3251
|
-
});
|
3461
|
+
}, source);
|
3252
3462
|
};
|
3253
3463
|
|
3254
3464
|
/**
|
@@ -3261,18 +3471,18 @@ if (!Array.prototype.forEach) {
|
|
3261
3471
|
* @returns {Observable} An observable sequence that contains the specified number of elements from the start of the input sequence.
|
3262
3472
|
*/
|
3263
3473
|
observableProto.take = function (count, scheduler) {
|
3264
|
-
|
3265
|
-
|
3266
|
-
|
3267
|
-
|
3268
|
-
|
3269
|
-
|
3270
|
-
|
3271
|
-
|
3272
|
-
|
3273
|
-
|
3274
|
-
|
3275
|
-
|
3474
|
+
if (count < 0) { throw new RangeError(argumentOutOfRange); }
|
3475
|
+
if (count === 0) { return observableEmpty(scheduler); }
|
3476
|
+
var source = this;
|
3477
|
+
return new AnonymousObservable(function (observer) {
|
3478
|
+
var remaining = count;
|
3479
|
+
return source.subscribe(function (x) {
|
3480
|
+
if (remaining-- > 0) {
|
3481
|
+
observer.onNext(x);
|
3482
|
+
remaining === 0 && observer.onCompleted();
|
3483
|
+
}
|
3484
|
+
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
3485
|
+
}, source);
|
3276
3486
|
};
|
3277
3487
|
|
3278
3488
|
/**
|
@@ -3283,13 +3493,13 @@ if (!Array.prototype.forEach) {
|
|
3283
3493
|
* @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.
|
3284
3494
|
*/
|
3285
3495
|
observableProto.takeWhile = function (predicate, thisArg) {
|
3286
|
-
var
|
3496
|
+
var source = this;
|
3287
3497
|
return new AnonymousObservable(function (observer) {
|
3288
3498
|
var i = 0, running = true;
|
3289
|
-
return
|
3499
|
+
return source.subscribe(function (x) {
|
3290
3500
|
if (running) {
|
3291
3501
|
try {
|
3292
|
-
running = predicate.call(thisArg, x, i++,
|
3502
|
+
running = predicate.call(thisArg, x, i++, source);
|
3293
3503
|
} catch (e) {
|
3294
3504
|
observer.onError(e);
|
3295
3505
|
return;
|
@@ -3301,7 +3511,7 @@ if (!Array.prototype.forEach) {
|
|
3301
3511
|
}
|
3302
3512
|
}
|
3303
3513
|
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
3304
|
-
});
|
3514
|
+
}, source);
|
3305
3515
|
};
|
3306
3516
|
|
3307
3517
|
/**
|
@@ -3315,20 +3525,20 @@ if (!Array.prototype.forEach) {
|
|
3315
3525
|
* @returns {Observable} An observable sequence that contains elements from the input sequence that satisfy the condition.
|
3316
3526
|
*/
|
3317
3527
|
observableProto.where = observableProto.filter = function (predicate, thisArg) {
|
3318
|
-
|
3319
|
-
|
3320
|
-
|
3321
|
-
|
3322
|
-
|
3323
|
-
|
3324
|
-
|
3325
|
-
|
3326
|
-
|
3327
|
-
|
3328
|
-
|
3329
|
-
|
3330
|
-
|
3331
|
-
|
3528
|
+
var source = this;
|
3529
|
+
return new AnonymousObservable(function (observer) {
|
3530
|
+
var count = 0;
|
3531
|
+
return source.subscribe(function (value) {
|
3532
|
+
var shouldRun;
|
3533
|
+
try {
|
3534
|
+
shouldRun = predicate.call(thisArg, value, count++, parent);
|
3535
|
+
} catch (e) {
|
3536
|
+
observer.onError(e);
|
3537
|
+
return;
|
3538
|
+
}
|
3539
|
+
shouldRun && observer.onNext(value);
|
3540
|
+
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
3541
|
+
}, source);
|
3332
3542
|
};
|
3333
3543
|
|
3334
3544
|
/**
|
@@ -3344,12 +3554,12 @@ if (!Array.prototype.forEach) {
|
|
3344
3554
|
var args = slice.call(arguments, 0);
|
3345
3555
|
|
3346
3556
|
return new AnonymousObservable(function (observer) {
|
3347
|
-
function handler(
|
3348
|
-
var results =
|
3557
|
+
function handler() {
|
3558
|
+
var results = arguments;
|
3349
3559
|
|
3350
3560
|
if (selector) {
|
3351
3561
|
try {
|
3352
|
-
results = selector(
|
3562
|
+
results = selector(results);
|
3353
3563
|
} catch (err) {
|
3354
3564
|
observer.onError(err);
|
3355
3565
|
return;
|
@@ -3446,12 +3656,12 @@ if (!Array.prototype.forEach) {
|
|
3446
3656
|
event.relatedTarget = event.toElement;
|
3447
3657
|
}
|
3448
3658
|
// Adding stopPropogation and preventDefault to IE
|
3449
|
-
if (!event.stopPropagation){
|
3659
|
+
if (!event.stopPropagation) {
|
3450
3660
|
event.stopPropagation = stopPropagation;
|
3451
3661
|
event.preventDefault = preventDefault;
|
3452
3662
|
}
|
3453
3663
|
// Normalize key events
|
3454
|
-
switch(event.type){
|
3664
|
+
switch (event.type) {
|
3455
3665
|
case 'keypress':
|
3456
3666
|
var c = ('charCode' in event ? event.charCode : event.keyCode);
|
3457
3667
|
if (c == 10) {
|
@@ -3634,10 +3844,8 @@ if (!Array.prototype.forEach) {
|
|
3634
3844
|
|
3635
3845
|
promise.then(
|
3636
3846
|
function (value) {
|
3637
|
-
|
3638
|
-
|
3639
|
-
subject.onCompleted();
|
3640
|
-
}
|
3847
|
+
subject.onNext(value);
|
3848
|
+
subject.onCompleted();
|
3641
3849
|
},
|
3642
3850
|
subject.onError.bind(subject));
|
3643
3851
|
|
@@ -3710,7 +3918,7 @@ if (!Array.prototype.forEach) {
|
|
3710
3918
|
new AnonymousObservable(function (observer) {
|
3711
3919
|
var connectable = source.multicast(subjectOrSubjectSelector());
|
3712
3920
|
return new CompositeDisposable(selector(connectable).subscribe(observer), connectable.connect());
|
3713
|
-
}) :
|
3921
|
+
}, source) :
|
3714
3922
|
new ConnectableObservable(source, subjectOrSubjectSelector);
|
3715
3923
|
};
|
3716
3924
|
|
@@ -3734,10 +3942,6 @@ if (!Array.prototype.forEach) {
|
|
3734
3942
|
/**
|
3735
3943
|
* Returns an observable sequence that shares a single subscription to the underlying sequence.
|
3736
3944
|
* 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.
|
3737
|
-
*
|
3738
|
-
* @example
|
3739
|
-
* var res = source.share();
|
3740
|
-
*
|
3741
3945
|
* @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence.
|
3742
3946
|
*/
|
3743
3947
|
observableProto.share = function () {
|
@@ -3784,10 +3988,6 @@ if (!Array.prototype.forEach) {
|
|
3784
3988
|
/**
|
3785
3989
|
* Returns an observable sequence that shares a single subscription to the underlying sequence and starts with an initialValue.
|
3786
3990
|
* 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.
|
3787
|
-
*
|
3788
|
-
* @example
|
3789
|
-
* var res = source.shareValue(42);
|
3790
|
-
*
|
3791
3991
|
* @param {Mixed} initialValue Initial value received by observers upon subscription.
|
3792
3992
|
* @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence.
|
3793
3993
|
*/
|
@@ -4022,7 +4222,7 @@ if (!Array.prototype.forEach) {
|
|
4022
4222
|
}
|
4023
4223
|
});
|
4024
4224
|
return new CompositeDisposable(subscription, cancelable);
|
4025
|
-
});
|
4225
|
+
}, source);
|
4026
4226
|
}
|
4027
4227
|
|
4028
4228
|
function observableDelayDate(source, dueTime, scheduler) {
|
@@ -4054,16 +4254,11 @@ if (!Array.prototype.forEach) {
|
|
4054
4254
|
|
4055
4255
|
/**
|
4056
4256
|
* Ignores values from an observable sequence which are followed by another value before dueTime.
|
4057
|
-
*
|
4058
|
-
* @
|
4059
|
-
*
|
4060
|
-
* 2 - res = source.throttle(5000, scheduler);
|
4061
|
-
*
|
4062
|
-
* @param {Number} dueTime Duration of the throttle period for each value (specified as an integer denoting milliseconds).
|
4063
|
-
* @param {Scheduler} [scheduler] Scheduler to run the throttle timers on. If not specified, the timeout scheduler is used.
|
4064
|
-
* @returns {Observable} The throttled sequence.
|
4257
|
+
* @param {Number} dueTime Duration of the debounce period for each value (specified as an integer denoting milliseconds).
|
4258
|
+
* @param {Scheduler} [scheduler] Scheduler to run the debounce timers on. If not specified, the timeout scheduler is used.
|
4259
|
+
* @returns {Observable} The debounced sequence.
|
4065
4260
|
*/
|
4066
|
-
observableProto.
|
4261
|
+
observableProto.debounce = observableProto.throttleWithTimeout = function (dueTime, scheduler) {
|
4067
4262
|
isScheduler(scheduler) || (scheduler = timeoutScheduler);
|
4068
4263
|
var source = this;
|
4069
4264
|
return new AnonymousObservable(function (observer) {
|
@@ -4095,7 +4290,15 @@ if (!Array.prototype.forEach) {
|
|
4095
4290
|
id++;
|
4096
4291
|
});
|
4097
4292
|
return new CompositeDisposable(subscription, cancelable);
|
4098
|
-
});
|
4293
|
+
}, this);
|
4294
|
+
};
|
4295
|
+
|
4296
|
+
/**
|
4297
|
+
* @deprecated use #debounce or #throttleWithTimeout instead.
|
4298
|
+
*/
|
4299
|
+
observableProto.throttle = function(dueTime, scheduler) {
|
4300
|
+
deprecate('throttle', 'debounce or throttleWithTimeout');
|
4301
|
+
return this.debounce(dueTime, scheduler);
|
4099
4302
|
};
|
4100
4303
|
|
4101
4304
|
/**
|
@@ -4116,7 +4319,6 @@ if (!Array.prototype.forEach) {
|
|
4116
4319
|
};
|
4117
4320
|
|
4118
4321
|
function sampleObservable(source, sampler) {
|
4119
|
-
|
4120
4322
|
return new AnonymousObservable(function (observer) {
|
4121
4323
|
var atEnd, value, hasValue;
|
4122
4324
|
|
@@ -4137,7 +4339,7 @@ if (!Array.prototype.forEach) {
|
|
4137
4339
|
}),
|
4138
4340
|
sampler.subscribe(sampleSubscribe, observer.onError.bind(observer), sampleSubscribe)
|
4139
4341
|
);
|
4140
|
-
});
|
4342
|
+
}, source);
|
4141
4343
|
}
|
4142
4344
|
|
4143
4345
|
/**
|
@@ -4152,7 +4354,7 @@ if (!Array.prototype.forEach) {
|
|
4152
4354
|
* @param {Scheduler} [scheduler] Scheduler to run the sampling timer on. If not specified, the timeout scheduler is used.
|
4153
4355
|
* @returns {Observable} Sampled observable sequence.
|
4154
4356
|
*/
|
4155
|
-
observableProto.sample = function (intervalOrSampler, scheduler) {
|
4357
|
+
observableProto.sample = observableProto.throttleLatest = function (intervalOrSampler, scheduler) {
|
4156
4358
|
isScheduler(scheduler) || (scheduler = timeoutScheduler);
|
4157
4359
|
return typeof intervalOrSampler === 'number' ?
|
4158
4360
|
sampleObservable(this, observableinterval(intervalOrSampler, scheduler)) :
|
@@ -4213,7 +4415,34 @@ if (!Array.prototype.forEach) {
|
|
4213
4415
|
}
|
4214
4416
|
}));
|
4215
4417
|
return new CompositeDisposable(subscription, timer);
|
4216
|
-
});
|
4418
|
+
}, source);
|
4419
|
+
};
|
4420
|
+
|
4421
|
+
/**
|
4422
|
+
* Returns an Observable that emits only the first item emitted by the source Observable during sequential time windows of a specified duration.
|
4423
|
+
* @param {Number} windowDuration time to wait before emitting another item after emitting the last item
|
4424
|
+
* @param {Scheduler} [scheduler] the Scheduler to use internally to manage the timers that handle timeout for each item. If not provided, defaults to Scheduler.timeout.
|
4425
|
+
* @returns {Observable} An Observable that performs the throttle operation.
|
4426
|
+
*/
|
4427
|
+
observableProto.throttleFirst = function (windowDuration, scheduler) {
|
4428
|
+
isScheduler(scheduler) || (scheduler = timeoutScheduler);
|
4429
|
+
var duration = +windowDuration || 0;
|
4430
|
+
if (duration <= 0) { throw new RangeError('windowDuration cannot be less or equal zero.'); }
|
4431
|
+
var source = this;
|
4432
|
+
return new AnonymousObservable(function (observer) {
|
4433
|
+
var lastOnNext = 0;
|
4434
|
+
return source.subscribe(
|
4435
|
+
function (x) {
|
4436
|
+
var now = scheduler.now();
|
4437
|
+
if (lastOnNext === 0 || now - lastOnNext >= duration) {
|
4438
|
+
lastOnNext = now;
|
4439
|
+
observer.onNext(x);
|
4440
|
+
}
|
4441
|
+
},
|
4442
|
+
observer.onError.bind(observer),
|
4443
|
+
observer.onCompleted.bind(observer)
|
4444
|
+
);
|
4445
|
+
}, source);
|
4217
4446
|
};
|
4218
4447
|
|
4219
4448
|
var PausableObservable = (function (_super) {
|
@@ -4276,17 +4505,22 @@ if (!Array.prototype.forEach) {
|
|
4276
4505
|
|
4277
4506
|
function combineLatestSource(source, subject, resultSelector) {
|
4278
4507
|
return new AnonymousObservable(function (observer) {
|
4279
|
-
var
|
4280
|
-
hasValue = [false, false],
|
4508
|
+
var hasValue = [false, false],
|
4281
4509
|
hasValueAll = false,
|
4282
4510
|
isDone = false,
|
4283
|
-
values = new Array(
|
4511
|
+
values = new Array(2),
|
4512
|
+
err;
|
4284
4513
|
|
4285
4514
|
function next(x, i) {
|
4286
4515
|
values[i] = x
|
4287
4516
|
var res;
|
4288
4517
|
hasValue[i] = true;
|
4289
4518
|
if (hasValueAll || (hasValueAll = hasValue.every(identity))) {
|
4519
|
+
if (err) {
|
4520
|
+
observer.onError(err);
|
4521
|
+
return;
|
4522
|
+
}
|
4523
|
+
|
4290
4524
|
try {
|
4291
4525
|
res = resultSelector.apply(null, values);
|
4292
4526
|
} catch (ex) {
|
@@ -4294,7 +4528,8 @@ if (!Array.prototype.forEach) {
|
|
4294
4528
|
return;
|
4295
4529
|
}
|
4296
4530
|
observer.onNext(res);
|
4297
|
-
}
|
4531
|
+
}
|
4532
|
+
if (isDone && values[1]) {
|
4298
4533
|
observer.onCompleted();
|
4299
4534
|
}
|
4300
4535
|
}
|
@@ -4304,23 +4539,33 @@ if (!Array.prototype.forEach) {
|
|
4304
4539
|
function (x) {
|
4305
4540
|
next(x, 0);
|
4306
4541
|
},
|
4307
|
-
|
4542
|
+
function (e) {
|
4543
|
+
if (values[1]) {
|
4544
|
+
observer.onError(e);
|
4545
|
+
} else {
|
4546
|
+
err = e;
|
4547
|
+
}
|
4548
|
+
},
|
4308
4549
|
function () {
|
4309
4550
|
isDone = true;
|
4310
|
-
observer.onCompleted();
|
4551
|
+
values[1] && observer.onCompleted();
|
4311
4552
|
}),
|
4312
4553
|
subject.subscribe(
|
4313
4554
|
function (x) {
|
4314
4555
|
next(x, 1);
|
4315
4556
|
},
|
4316
|
-
observer.onError.bind(observer)
|
4557
|
+
observer.onError.bind(observer),
|
4558
|
+
function () {
|
4559
|
+
isDone = true;
|
4560
|
+
next(true, 1);
|
4561
|
+
})
|
4317
4562
|
);
|
4318
4563
|
});
|
4319
4564
|
}
|
4320
4565
|
|
4321
|
-
var PausableBufferedObservable = (function (
|
4566
|
+
var PausableBufferedObservable = (function (__super__) {
|
4322
4567
|
|
4323
|
-
inherits(PausableBufferedObservable,
|
4568
|
+
inherits(PausableBufferedObservable, __super__);
|
4324
4569
|
|
4325
4570
|
function subscribe(observer) {
|
4326
4571
|
var q = [], previousShouldFire;
|
@@ -4380,7 +4625,7 @@ if (!Array.prototype.forEach) {
|
|
4380
4625
|
this.pauser = this.controller;
|
4381
4626
|
}
|
4382
4627
|
|
4383
|
-
|
4628
|
+
__super__.call(this, subscribe);
|
4384
4629
|
}
|
4385
4630
|
|
4386
4631
|
PausableBufferedObservable.prototype.pause = function () {
|
@@ -4572,7 +4817,7 @@ if (!Array.prototype.forEach) {
|
|
4572
4817
|
}(Observable));
|
4573
4818
|
|
4574
4819
|
/**
|
4575
|
-
* Executes a transducer to transform the observable sequence
|
4820
|
+
* Executes a transducer to transform the observable sequence
|
4576
4821
|
* @param {Transducer} transducer A transducer to execute
|
4577
4822
|
* @returns {Observable} An Observable sequence containing the results from the transducer.
|
4578
4823
|
*/
|
@@ -4596,17 +4841,17 @@ if (!Array.prototype.forEach) {
|
|
4596
4841
|
return new AnonymousObservable(function(observer) {
|
4597
4842
|
var xform = transducer(transformForObserver(observer));
|
4598
4843
|
return source.subscribe(
|
4599
|
-
function(v) {
|
4844
|
+
function(v) {
|
4600
4845
|
try {
|
4601
4846
|
xform.step(observer, v);
|
4602
4847
|
} catch (e) {
|
4603
4848
|
observer.onError(e);
|
4604
4849
|
}
|
4605
|
-
},
|
4606
|
-
observer.onError.bind(observer),
|
4850
|
+
},
|
4851
|
+
observer.onError.bind(observer),
|
4607
4852
|
function() { xform.result(observer); }
|
4608
4853
|
);
|
4609
|
-
});
|
4854
|
+
}, source);
|
4610
4855
|
};
|
4611
4856
|
|
4612
4857
|
var AnonymousObservable = Rx.AnonymousObservable = (function (__super__) {
|
@@ -4621,7 +4866,8 @@ if (!Array.prototype.forEach) {
|
|
4621
4866
|
disposableEmpty;
|
4622
4867
|
}
|
4623
4868
|
|
4624
|
-
function AnonymousObservable(subscribe) {
|
4869
|
+
function AnonymousObservable(subscribe, parent) {
|
4870
|
+
this.source = parent;
|
4625
4871
|
if (!(this instanceof AnonymousObservable)) {
|
4626
4872
|
return new AnonymousObservable(subscribe);
|
4627
4873
|
}
|
@@ -4654,66 +4900,59 @@ if (!Array.prototype.forEach) {
|
|
4654
4900
|
|
4655
4901
|
}(Observable));
|
4656
4902
|
|
4657
|
-
|
4658
|
-
|
4659
|
-
inherits(AutoDetachObserver, _super);
|
4903
|
+
var AutoDetachObserver = (function (__super__) {
|
4904
|
+
inherits(AutoDetachObserver, __super__);
|
4660
4905
|
|
4661
|
-
|
4662
|
-
|
4663
|
-
|
4664
|
-
|
4665
|
-
|
4906
|
+
function AutoDetachObserver(observer) {
|
4907
|
+
__super__.call(this);
|
4908
|
+
this.observer = observer;
|
4909
|
+
this.m = new SingleAssignmentDisposable();
|
4910
|
+
}
|
4666
4911
|
|
4667
|
-
|
4912
|
+
var AutoDetachObserverPrototype = AutoDetachObserver.prototype;
|
4668
4913
|
|
4669
|
-
|
4670
|
-
|
4671
|
-
|
4672
|
-
|
4673
|
-
|
4674
|
-
|
4675
|
-
|
4676
|
-
|
4677
|
-
|
4678
|
-
|
4679
|
-
|
4680
|
-
}
|
4681
|
-
};
|
4914
|
+
AutoDetachObserverPrototype.next = function (value) {
|
4915
|
+
var noError = false;
|
4916
|
+
try {
|
4917
|
+
this.observer.onNext(value);
|
4918
|
+
noError = true;
|
4919
|
+
} catch (e) {
|
4920
|
+
throw e;
|
4921
|
+
} finally {
|
4922
|
+
!noError && this.dispose();
|
4923
|
+
}
|
4924
|
+
};
|
4682
4925
|
|
4683
|
-
|
4684
|
-
|
4685
|
-
|
4686
|
-
|
4687
|
-
|
4688
|
-
|
4689
|
-
|
4690
|
-
|
4691
|
-
|
4926
|
+
AutoDetachObserverPrototype.error = function (err) {
|
4927
|
+
try {
|
4928
|
+
this.observer.onError(err);
|
4929
|
+
} catch (e) {
|
4930
|
+
throw e;
|
4931
|
+
} finally {
|
4932
|
+
this.dispose();
|
4933
|
+
}
|
4934
|
+
};
|
4692
4935
|
|
4693
|
-
|
4694
|
-
|
4695
|
-
|
4696
|
-
|
4697
|
-
|
4698
|
-
|
4699
|
-
|
4700
|
-
|
4701
|
-
|
4936
|
+
AutoDetachObserverPrototype.completed = function () {
|
4937
|
+
try {
|
4938
|
+
this.observer.onCompleted();
|
4939
|
+
} catch (e) {
|
4940
|
+
throw e;
|
4941
|
+
} finally {
|
4942
|
+
this.dispose();
|
4943
|
+
}
|
4944
|
+
};
|
4702
4945
|
|
4703
|
-
|
4704
|
-
|
4705
|
-
/* @private */
|
4706
|
-
AutoDetachObserverPrototype.disposable = function (value) {
|
4707
|
-
return arguments.length ? this.getDisposable() : setDisposable(value);
|
4708
|
-
};
|
4946
|
+
AutoDetachObserverPrototype.setDisposable = function (value) { this.m.setDisposable(value); };
|
4947
|
+
AutoDetachObserverPrototype.getDisposable = function () { return this.m.getDisposable(); };
|
4709
4948
|
|
4710
|
-
|
4711
|
-
|
4712
|
-
|
4713
|
-
|
4949
|
+
AutoDetachObserverPrototype.dispose = function () {
|
4950
|
+
__super__.prototype.dispose.call(this);
|
4951
|
+
this.m.dispose();
|
4952
|
+
};
|
4714
4953
|
|
4715
|
-
|
4716
|
-
|
4954
|
+
return AutoDetachObserver;
|
4955
|
+
}(AbstractObserver));
|
4717
4956
|
|
4718
4957
|
/** @private */
|
4719
4958
|
var InnerSubscription = function (subject, observer) {
|
@@ -5109,21 +5348,17 @@ if (!Array.prototype.forEach) {
|
|
5109
5348
|
this._trim(this.scheduler.now());
|
5110
5349
|
this.observers.push(so);
|
5111
5350
|
|
5112
|
-
var n = this.q.length;
|
5113
|
-
|
5114
5351
|
for (var i = 0, len = this.q.length; i < len; i++) {
|
5115
5352
|
so.onNext(this.q[i].value);
|
5116
5353
|
}
|
5117
5354
|
|
5118
5355
|
if (this.hasError) {
|
5119
|
-
n++;
|
5120
5356
|
so.onError(this.error);
|
5121
5357
|
} else if (this.isStopped) {
|
5122
|
-
n++;
|
5123
5358
|
so.onCompleted();
|
5124
5359
|
}
|
5125
5360
|
|
5126
|
-
so.ensureActive(
|
5361
|
+
so.ensureActive();
|
5127
5362
|
return subscription;
|
5128
5363
|
}
|
5129
5364
|
|
@@ -5249,4 +5484,7 @@ if (!Array.prototype.forEach) {
|
|
5249
5484
|
root.Rx = Rx;
|
5250
5485
|
}
|
5251
5486
|
|
5487
|
+
// All code before this point will be filtered from stack traces.
|
5488
|
+
var rEndingLine = captureLine();
|
5489
|
+
|
5252
5490
|
}.call(this));
|