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:
|
@@ -1175,15 +1288,13 @@ if (!Array.prototype.forEach) {
|
|
1175
1288
|
return SchedulePeriodicRecursive;
|
1176
1289
|
}());
|
1177
1290
|
|
1178
|
-
/**
|
1179
|
-
* Gets a scheduler that schedules work immediately on the current thread.
|
1180
|
-
*/
|
1291
|
+
/** Gets a scheduler that schedules work immediately on the current thread. */
|
1181
1292
|
var immediateScheduler = Scheduler.immediate = (function () {
|
1182
1293
|
|
1183
1294
|
function scheduleNow(state, action) { return action(this, state); }
|
1184
1295
|
|
1185
1296
|
function scheduleRelative(state, dueTime, action) {
|
1186
|
-
var dt = normalizeTime(
|
1297
|
+
var dt = normalizeTime(dueTime);
|
1187
1298
|
while (dt - this.now() > 0) { }
|
1188
1299
|
return action(this, state);
|
1189
1300
|
}
|
@@ -1297,24 +1408,24 @@ if (!Array.prototype.forEach) {
|
|
1297
1408
|
oldHandler = root.onmessage;
|
1298
1409
|
// Test for async
|
1299
1410
|
root.onmessage = function () { isAsync = true; };
|
1300
|
-
root.postMessage('','*');
|
1411
|
+
root.postMessage('', '*');
|
1301
1412
|
root.onmessage = oldHandler;
|
1302
1413
|
|
1303
1414
|
return isAsync;
|
1304
1415
|
}
|
1305
1416
|
|
1306
|
-
// Use in order,
|
1307
|
-
if (typeof
|
1308
|
-
scheduleMethod = process.nextTick;
|
1309
|
-
} else if (typeof setImmediate === 'function') {
|
1417
|
+
// Use in order, setImmediate, nextTick, postMessage, MessageChannel, script readystatechanged, setTimeout
|
1418
|
+
if (typeof setImmediate === 'function') {
|
1310
1419
|
scheduleMethod = setImmediate;
|
1311
1420
|
clearMethod = clearImmediate;
|
1421
|
+
} else if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') {
|
1422
|
+
scheduleMethod = process.nextTick;
|
1312
1423
|
} else if (postMessageSupported()) {
|
1313
1424
|
var MSG_PREFIX = 'ms.rx.schedule' + Math.random(),
|
1314
1425
|
tasks = {},
|
1315
1426
|
taskId = 0;
|
1316
1427
|
|
1317
|
-
function
|
1428
|
+
var onGlobalPostMessage = function (event) {
|
1318
1429
|
// Only if we're a match to avoid any other global events
|
1319
1430
|
if (typeof event.data === 'string' && event.data.substring(0, MSG_PREFIX.length) === MSG_PREFIX) {
|
1320
1431
|
var handleId = event.data.substring(MSG_PREFIX.length),
|
@@ -1615,8 +1726,8 @@ if (!Array.prototype.forEach) {
|
|
1615
1726
|
var e;
|
1616
1727
|
try {
|
1617
1728
|
e = sources[$iterator$]();
|
1618
|
-
} catch(err) {
|
1619
|
-
observer.onError();
|
1729
|
+
} catch (err) {
|
1730
|
+
observer.onError(err);
|
1620
1731
|
return;
|
1621
1732
|
}
|
1622
1733
|
|
@@ -1657,14 +1768,14 @@ if (!Array.prototype.forEach) {
|
|
1657
1768
|
});
|
1658
1769
|
};
|
1659
1770
|
|
1660
|
-
Enumerable.prototype.
|
1771
|
+
Enumerable.prototype.catchError = function () {
|
1661
1772
|
var sources = this;
|
1662
1773
|
return new AnonymousObservable(function (observer) {
|
1663
1774
|
var e;
|
1664
1775
|
try {
|
1665
1776
|
e = sources[$iterator$]();
|
1666
|
-
} catch(err) {
|
1667
|
-
observer.onError();
|
1777
|
+
} catch (err) {
|
1778
|
+
observer.onError(err);
|
1668
1779
|
return;
|
1669
1780
|
}
|
1670
1781
|
|
@@ -1802,7 +1913,7 @@ if (!Array.prototype.forEach) {
|
|
1802
1913
|
* @param {Scheduler} scheduler Scheduler to schedule observer messages on.
|
1803
1914
|
* @returns {Observer} Observer whose messages are scheduled on the given scheduler.
|
1804
1915
|
*/
|
1805
|
-
Observer.notifyOn = function (scheduler) {
|
1916
|
+
Observer.prototype.notifyOn = function (scheduler) {
|
1806
1917
|
return new ObserveOnObserver(scheduler, this);
|
1807
1918
|
};
|
1808
1919
|
|
@@ -1983,23 +2094,17 @@ if (!Array.prototype.forEach) {
|
|
1983
2094
|
|
1984
2095
|
ScheduledObserver.prototype.next = function (value) {
|
1985
2096
|
var self = this;
|
1986
|
-
this.queue.push(function () {
|
1987
|
-
self.observer.onNext(value);
|
1988
|
-
});
|
2097
|
+
this.queue.push(function () { self.observer.onNext(value); });
|
1989
2098
|
};
|
1990
2099
|
|
1991
|
-
ScheduledObserver.prototype.error = function (
|
2100
|
+
ScheduledObserver.prototype.error = function (e) {
|
1992
2101
|
var self = this;
|
1993
|
-
this.queue.push(function () {
|
1994
|
-
self.observer.onError(err);
|
1995
|
-
});
|
2102
|
+
this.queue.push(function () { self.observer.onError(e); });
|
1996
2103
|
};
|
1997
2104
|
|
1998
2105
|
ScheduledObserver.prototype.completed = function () {
|
1999
2106
|
var self = this;
|
2000
|
-
this.queue.push(function () {
|
2001
|
-
self.observer.onCompleted();
|
2002
|
-
});
|
2107
|
+
this.queue.push(function () { self.observer.onCompleted(); });
|
2003
2108
|
};
|
2004
2109
|
|
2005
2110
|
ScheduledObserver.prototype.ensureActive = function () {
|
@@ -2040,8 +2145,9 @@ if (!Array.prototype.forEach) {
|
|
2040
2145
|
var ObserveOnObserver = (function (__super__) {
|
2041
2146
|
inherits(ObserveOnObserver, __super__);
|
2042
2147
|
|
2043
|
-
function ObserveOnObserver() {
|
2044
|
-
__super__.
|
2148
|
+
function ObserveOnObserver(scheduler, observer, cancel) {
|
2149
|
+
__super__.call(this, scheduler, observer);
|
2150
|
+
this._cancel = cancel;
|
2045
2151
|
}
|
2046
2152
|
|
2047
2153
|
ObserveOnObserver.prototype.next = function (value) {
|
@@ -2059,6 +2165,12 @@ if (!Array.prototype.forEach) {
|
|
2059
2165
|
this.ensureActive();
|
2060
2166
|
};
|
2061
2167
|
|
2168
|
+
ObserveOnObserver.prototype.dispose = function () {
|
2169
|
+
__super__.prototype.dispose.call(this);
|
2170
|
+
this._cancel && this._cancel.dispose();
|
2171
|
+
this._cancel = null;
|
2172
|
+
};
|
2173
|
+
|
2062
2174
|
return ObserveOnObserver;
|
2063
2175
|
})(ScheduledObserver);
|
2064
2176
|
|
@@ -2070,6 +2182,24 @@ if (!Array.prototype.forEach) {
|
|
2070
2182
|
var Observable = Rx.Observable = (function () {
|
2071
2183
|
|
2072
2184
|
function Observable(subscribe) {
|
2185
|
+
if (Rx.config.longStackSupport && hasStacks) {
|
2186
|
+
try {
|
2187
|
+
throw new Error();
|
2188
|
+
} catch (e) {
|
2189
|
+
this.stack = e.stack.substring(e.stack.indexOf("\n") + 1);
|
2190
|
+
}
|
2191
|
+
|
2192
|
+
var self = this;
|
2193
|
+
this._subscribe = function (observer) {
|
2194
|
+
observer.onError = function (err) {
|
2195
|
+
makeStackTraceLong(self, err);
|
2196
|
+
observer.onError(err);
|
2197
|
+
};
|
2198
|
+
|
2199
|
+
subscribe(observer);
|
2200
|
+
};
|
2201
|
+
}
|
2202
|
+
|
2073
2203
|
this._subscribe = subscribe;
|
2074
2204
|
}
|
2075
2205
|
|
@@ -2134,7 +2264,7 @@ if (!Array.prototype.forEach) {
|
|
2134
2264
|
var source = this;
|
2135
2265
|
return new AnonymousObservable(function (observer) {
|
2136
2266
|
return source.subscribe(new ObserveOnObserver(scheduler, observer));
|
2137
|
-
});
|
2267
|
+
}, source);
|
2138
2268
|
};
|
2139
2269
|
|
2140
2270
|
/**
|
@@ -2156,7 +2286,7 @@ if (!Array.prototype.forEach) {
|
|
2156
2286
|
d.setDisposable(new ScheduledDisposable(scheduler, source.subscribe(observer)));
|
2157
2287
|
}));
|
2158
2288
|
return d;
|
2159
|
-
});
|
2289
|
+
}, source);
|
2160
2290
|
};
|
2161
2291
|
|
2162
2292
|
/**
|
@@ -2170,10 +2300,8 @@ if (!Array.prototype.forEach) {
|
|
2170
2300
|
|
2171
2301
|
promise.then(
|
2172
2302
|
function (value) {
|
2173
|
-
|
2174
|
-
|
2175
|
-
subject.onCompleted();
|
2176
|
-
}
|
2303
|
+
subject.onNext(value);
|
2304
|
+
subject.onCompleted();
|
2177
2305
|
},
|
2178
2306
|
subject.onError.bind(subject));
|
2179
2307
|
|
@@ -2209,36 +2337,34 @@ if (!Array.prototype.forEach) {
|
|
2209
2337
|
};
|
2210
2338
|
|
2211
2339
|
/**
|
2212
|
-
* Creates
|
2213
|
-
* @returns An observable sequence containing a single element with a list containing all the elements of the source sequence.
|
2340
|
+
* Creates an array from an observable sequence.
|
2341
|
+
* @returns {Observable} An observable sequence containing a single element with a list containing all the elements of the source sequence.
|
2214
2342
|
*/
|
2215
2343
|
observableProto.toArray = function () {
|
2216
|
-
var
|
2344
|
+
var source = this;
|
2217
2345
|
return new AnonymousObservable(function(observer) {
|
2218
2346
|
var arr = [];
|
2219
|
-
return
|
2347
|
+
return source.subscribe(
|
2220
2348
|
arr.push.bind(arr),
|
2221
2349
|
observer.onError.bind(observer),
|
2222
2350
|
function () {
|
2223
2351
|
observer.onNext(arr);
|
2224
2352
|
observer.onCompleted();
|
2225
2353
|
});
|
2226
|
-
});
|
2354
|
+
}, source);
|
2227
2355
|
};
|
2228
2356
|
|
2229
2357
|
/**
|
2230
2358
|
* Creates an observable sequence from a specified subscribe method implementation.
|
2231
|
-
*
|
2232
2359
|
* @example
|
2233
2360
|
* var res = Rx.Observable.create(function (observer) { return function () { } );
|
2234
2361
|
* var res = Rx.Observable.create(function (observer) { return Rx.Disposable.empty; } );
|
2235
2362
|
* var res = Rx.Observable.create(function (observer) { } );
|
2236
|
-
*
|
2237
2363
|
* @param {Function} subscribe Implementation of the resulting observable sequence's subscribe method, returning a function that will be wrapped in a Disposable.
|
2238
2364
|
* @returns {Observable} The observable sequence with the specified implementation for the Subscribe method.
|
2239
2365
|
*/
|
2240
|
-
Observable.create = Observable.createWithDisposable = function (subscribe) {
|
2241
|
-
return new AnonymousObservable(subscribe);
|
2366
|
+
Observable.create = Observable.createWithDisposable = function (subscribe, parent) {
|
2367
|
+
return new AnonymousObservable(subscribe, parent);
|
2242
2368
|
};
|
2243
2369
|
|
2244
2370
|
/**
|
@@ -2282,6 +2408,60 @@ if (!Array.prototype.forEach) {
|
|
2282
2408
|
|
2283
2409
|
var maxSafeInteger = Math.pow(2, 53) - 1;
|
2284
2410
|
|
2411
|
+
function StringIterable(str) {
|
2412
|
+
this._s = s;
|
2413
|
+
}
|
2414
|
+
|
2415
|
+
StringIterable.prototype[$iterator$] = function () {
|
2416
|
+
return new StringIterator(this._s);
|
2417
|
+
};
|
2418
|
+
|
2419
|
+
function StringIterator(str) {
|
2420
|
+
this._s = s;
|
2421
|
+
this._l = s.length;
|
2422
|
+
this._i = 0;
|
2423
|
+
}
|
2424
|
+
|
2425
|
+
StringIterator.prototype[$iterator$] = function () {
|
2426
|
+
return this;
|
2427
|
+
};
|
2428
|
+
|
2429
|
+
StringIterator.prototype.next = function () {
|
2430
|
+
if (this._i < this._l) {
|
2431
|
+
var val = this._s.charAt(this._i++);
|
2432
|
+
return { done: false, value: val };
|
2433
|
+
} else {
|
2434
|
+
return doneEnumerator;
|
2435
|
+
}
|
2436
|
+
};
|
2437
|
+
|
2438
|
+
function ArrayIterable(a) {
|
2439
|
+
this._a = a;
|
2440
|
+
}
|
2441
|
+
|
2442
|
+
ArrayIterable.prototype[$iterator$] = function () {
|
2443
|
+
return new ArrayIterator(this._a);
|
2444
|
+
};
|
2445
|
+
|
2446
|
+
function ArrayIterator(a) {
|
2447
|
+
this._a = a;
|
2448
|
+
this._l = toLength(a);
|
2449
|
+
this._i = 0;
|
2450
|
+
}
|
2451
|
+
|
2452
|
+
ArrayIterator.prototype[$iterator$] = function () {
|
2453
|
+
return this;
|
2454
|
+
};
|
2455
|
+
|
2456
|
+
ArrayIterator.prototype.next = function () {
|
2457
|
+
if (this._i < this._l) {
|
2458
|
+
var val = this._a[this._i++];
|
2459
|
+
return { done: false, value: val };
|
2460
|
+
} else {
|
2461
|
+
return doneEnumerator;
|
2462
|
+
}
|
2463
|
+
};
|
2464
|
+
|
2285
2465
|
function numberIsFinite(value) {
|
2286
2466
|
return typeof value === 'number' && root.isFinite(value);
|
2287
2467
|
}
|
@@ -2290,8 +2470,18 @@ if (!Array.prototype.forEach) {
|
|
2290
2470
|
return n !== n;
|
2291
2471
|
}
|
2292
2472
|
|
2293
|
-
function
|
2294
|
-
|
2473
|
+
function getIterable(o) {
|
2474
|
+
var i = o[$iterator$], it;
|
2475
|
+
if (!i && typeof o === 'string') {
|
2476
|
+
it = new StringIterable(o);
|
2477
|
+
return it[$iterator$]();
|
2478
|
+
}
|
2479
|
+
if (!i && o.length !== undefined) {
|
2480
|
+
it = new ArrayIterable(o);
|
2481
|
+
return it[$iterator$]();
|
2482
|
+
}
|
2483
|
+
if (!i) { throw new TypeError('Object is not iterable'); }
|
2484
|
+
return o[$iterator$]();
|
2295
2485
|
}
|
2296
2486
|
|
2297
2487
|
function sign(value) {
|
@@ -2311,10 +2501,6 @@ if (!Array.prototype.forEach) {
|
|
2311
2501
|
return len;
|
2312
2502
|
}
|
2313
2503
|
|
2314
|
-
function isCallable(f) {
|
2315
|
-
return Object.prototype.toString.call(f) === '[object Function]' && typeof f === 'function';
|
2316
|
-
}
|
2317
|
-
|
2318
2504
|
/**
|
2319
2505
|
* This method creates a new Observable sequence from an array-like or iterable object.
|
2320
2506
|
* @param {Any} arrayLike An array-like or iterable object to convert to an Observable sequence.
|
@@ -2326,66 +2512,52 @@ if (!Array.prototype.forEach) {
|
|
2326
2512
|
if (iterable == null) {
|
2327
2513
|
throw new Error('iterable cannot be null.')
|
2328
2514
|
}
|
2329
|
-
if (mapFn && !
|
2515
|
+
if (mapFn && !isFunction(mapFn)) {
|
2330
2516
|
throw new Error('mapFn when provided must be a function');
|
2331
2517
|
}
|
2332
2518
|
isScheduler(scheduler) || (scheduler = currentThreadScheduler);
|
2519
|
+
var list = Object(iterable), it = getIterable(list);
|
2333
2520
|
return new AnonymousObservable(function (observer) {
|
2334
|
-
var
|
2335
|
-
objIsIterable = isIterable(list),
|
2336
|
-
len = objIsIterable ? 0 : toLength(list),
|
2337
|
-
it = objIsIterable ? list[$iterator$]() : null,
|
2338
|
-
i = 0;
|
2521
|
+
var i = 0;
|
2339
2522
|
return scheduler.scheduleRecursive(function (self) {
|
2340
|
-
|
2341
|
-
|
2342
|
-
|
2343
|
-
|
2344
|
-
|
2345
|
-
|
2346
|
-
|
2347
|
-
|
2348
|
-
|
2349
|
-
|
2350
|
-
|
2351
|
-
observer.onCompleted();
|
2352
|
-
return;
|
2353
|
-
}
|
2523
|
+
var next;
|
2524
|
+
try {
|
2525
|
+
next = it.next();
|
2526
|
+
} catch (e) {
|
2527
|
+
observer.onError(e);
|
2528
|
+
return;
|
2529
|
+
}
|
2530
|
+
if (next.done) {
|
2531
|
+
observer.onCompleted();
|
2532
|
+
return;
|
2533
|
+
}
|
2354
2534
|
|
2355
|
-
|
2356
|
-
} else {
|
2357
|
-
result = !!list.charAt ? list.charAt(i) : list[i];
|
2358
|
-
}
|
2535
|
+
var result = next.value;
|
2359
2536
|
|
2360
|
-
|
2361
|
-
|
2362
|
-
|
2363
|
-
|
2364
|
-
|
2365
|
-
|
2366
|
-
}
|
2537
|
+
if (mapFn && isFunction(mapFn)) {
|
2538
|
+
try {
|
2539
|
+
result = mapFn.call(thisArg, result, i);
|
2540
|
+
} catch (e) {
|
2541
|
+
observer.onError(e);
|
2542
|
+
return;
|
2367
2543
|
}
|
2368
|
-
|
2369
|
-
observer.onNext(result);
|
2370
|
-
i++;
|
2371
|
-
self();
|
2372
|
-
} else {
|
2373
|
-
observer.onCompleted();
|
2374
2544
|
}
|
2545
|
+
|
2546
|
+
observer.onNext(result);
|
2547
|
+
i++;
|
2548
|
+
self();
|
2375
2549
|
});
|
2376
2550
|
});
|
2377
2551
|
};
|
2378
2552
|
|
2379
2553
|
/**
|
2380
2554
|
* Converts an array to an observable sequence, using an optional scheduler to enumerate the array.
|
2381
|
-
*
|
2382
|
-
* @example
|
2383
|
-
* var res = Rx.Observable.fromArray([1,2,3]);
|
2384
|
-
* var res = Rx.Observable.fromArray([1,2,3], Rx.Scheduler.timeout);
|
2555
|
+
* @deprecated use Observable.from or Observable.of
|
2385
2556
|
* @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on.
|
2386
2557
|
* @returns {Observable} The observable sequence whose elements are pulled from the given enumerable sequence.
|
2387
2558
|
*/
|
2388
2559
|
var observableFromArray = Observable.fromArray = function (array, scheduler) {
|
2560
|
+
deprecate('fromArray', 'from');
|
2389
2561
|
isScheduler(scheduler) || (scheduler = currentThreadScheduler);
|
2390
2562
|
return new AnonymousObservable(function (observer) {
|
2391
2563
|
var count = 0, len = array.length;
|
@@ -2443,29 +2615,36 @@ if (!Array.prototype.forEach) {
|
|
2443
2615
|
});
|
2444
2616
|
};
|
2445
2617
|
|
2618
|
+
function observableOf (scheduler, array) {
|
2619
|
+
isScheduler(scheduler) || (scheduler = currentThreadScheduler);
|
2620
|
+
return new AnonymousObservable(function (observer) {
|
2621
|
+
var count = 0, len = array.length;
|
2622
|
+
return scheduler.scheduleRecursive(function (self) {
|
2623
|
+
if (count < len) {
|
2624
|
+
observer.onNext(array[count++]);
|
2625
|
+
self();
|
2626
|
+
} else {
|
2627
|
+
observer.onCompleted();
|
2628
|
+
}
|
2629
|
+
});
|
2630
|
+
});
|
2631
|
+
}
|
2632
|
+
|
2446
2633
|
/**
|
2447
2634
|
* This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.
|
2448
|
-
* @example
|
2449
|
-
* var res = Rx.Observable.of(1,2,3);
|
2450
2635
|
* @returns {Observable} The observable sequence whose elements are pulled from the given arguments.
|
2451
2636
|
*/
|
2452
2637
|
Observable.of = function () {
|
2453
|
-
|
2454
|
-
for(var i = 0; i < len; i++) { args[i] = arguments[i]; }
|
2455
|
-
return observableFromArray(args);
|
2638
|
+
return observableOf(null, arguments);
|
2456
2639
|
};
|
2457
2640
|
|
2458
2641
|
/**
|
2459
2642
|
* This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.
|
2460
|
-
* @example
|
2461
|
-
* var res = Rx.Observable.of(1,2,3);
|
2462
2643
|
* @param {Scheduler} scheduler A scheduler to use for scheduling the arguments.
|
2463
2644
|
* @returns {Observable} The observable sequence whose elements are pulled from the given arguments.
|
2464
2645
|
*/
|
2465
|
-
|
2466
|
-
|
2467
|
-
for(var i = 0; i < len; i++) { args[i] = arguments[i + 1]; }
|
2468
|
-
return observableFromArray(args, scheduler);
|
2646
|
+
Observable.ofWithScheduler = function (scheduler) {
|
2647
|
+
return observableOf(scheduler, slice.call(arguments, 1));
|
2469
2648
|
};
|
2470
2649
|
|
2471
2650
|
/**
|
@@ -2532,7 +2711,7 @@ if (!Array.prototype.forEach) {
|
|
2532
2711
|
* @param {Scheduler} scheduler Scheduler to send the single element on. If not specified, defaults to Scheduler.immediate.
|
2533
2712
|
* @returns {Observable} An observable sequence containing the single specified element.
|
2534
2713
|
*/
|
2535
|
-
var observableReturn = Observable['return'] = Observable.
|
2714
|
+
var observableReturn = Observable['return'] = Observable.just = function (value, scheduler) {
|
2536
2715
|
isScheduler(scheduler) || (scheduler = immediateScheduler);
|
2537
2716
|
return new AnonymousObservable(function (observer) {
|
2538
2717
|
return scheduler.schedule(function () {
|
@@ -2542,6 +2721,12 @@ if (!Array.prototype.forEach) {
|
|
2542
2721
|
});
|
2543
2722
|
};
|
2544
2723
|
|
2724
|
+
/** @deprecated use return or just */
|
2725
|
+
Observable.returnValue = function () {
|
2726
|
+
deprecate('returnValue', 'return or just');
|
2727
|
+
return observableReturn.apply(null, arguments);
|
2728
|
+
};
|
2729
|
+
|
2545
2730
|
/**
|
2546
2731
|
* Returns an observable sequence that terminates with an exception, using the specified scheduler to send out the single onError message.
|
2547
2732
|
* There is an alias to this method called 'throwError' for browsers <IE9.
|
@@ -2684,7 +2869,7 @@ if (!Array.prototype.forEach) {
|
|
2684
2869
|
}, observer.onCompleted.bind(observer)));
|
2685
2870
|
|
2686
2871
|
return subscription;
|
2687
|
-
});
|
2872
|
+
}, source);
|
2688
2873
|
}
|
2689
2874
|
|
2690
2875
|
/**
|
@@ -2695,19 +2880,35 @@ if (!Array.prototype.forEach) {
|
|
2695
2880
|
* @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.
|
2696
2881
|
* @returns {Observable} An observable sequence containing the first sequence's elements, followed by the elements of the handler sequence in case an exception occurred.
|
2697
2882
|
*/
|
2698
|
-
observableProto['catch'] = observableProto.catchError =
|
2883
|
+
observableProto['catch'] = observableProto.catchError = function (handlerOrSecond) {
|
2699
2884
|
return typeof handlerOrSecond === 'function' ?
|
2700
2885
|
observableCatchHandler(this, handlerOrSecond) :
|
2701
2886
|
observableCatch([this, handlerOrSecond]);
|
2702
2887
|
};
|
2703
2888
|
|
2889
|
+
/**
|
2890
|
+
* @deprecated use #catch or #catchError instead.
|
2891
|
+
*/
|
2892
|
+
observableProto.catchException = function (handlerOrSecond) {
|
2893
|
+
deprecate('catchException', 'catch or catchError');
|
2894
|
+
return this.catchError(handlerOrSecond);
|
2895
|
+
};
|
2896
|
+
|
2704
2897
|
/**
|
2705
2898
|
* Continues an observable sequence that is terminated by an exception with the next observable sequence.
|
2706
2899
|
* @param {Array | Arguments} args Arguments or an array to use as the next sequence if an error occurs.
|
2707
2900
|
* @returns {Observable} An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.
|
2708
2901
|
*/
|
2709
|
-
var observableCatch = Observable.
|
2710
|
-
return enumerableOf(argsOrArray(arguments, 0)).
|
2902
|
+
var observableCatch = Observable.catchError = Observable['catch'] = function () {
|
2903
|
+
return enumerableOf(argsOrArray(arguments, 0)).catchError();
|
2904
|
+
};
|
2905
|
+
|
2906
|
+
/**
|
2907
|
+
* @deprecated use #catch or #catchError instead.
|
2908
|
+
*/
|
2909
|
+
Observable.catchException = function () {
|
2910
|
+
deprecate('catchException', 'catch or catchError');
|
2911
|
+
return observableCatch.apply(null, arguments);
|
2711
2912
|
};
|
2712
2913
|
|
2713
2914
|
/**
|
@@ -2791,7 +2992,7 @@ if (!Array.prototype.forEach) {
|
|
2791
2992
|
}
|
2792
2993
|
|
2793
2994
|
return new CompositeDisposable(subscriptions);
|
2794
|
-
});
|
2995
|
+
}, this);
|
2795
2996
|
};
|
2796
2997
|
|
2797
2998
|
/**
|
@@ -2817,13 +3018,19 @@ if (!Array.prototype.forEach) {
|
|
2817
3018
|
return enumerableOf(argsOrArray(arguments, 0)).concat();
|
2818
3019
|
};
|
2819
3020
|
|
2820
|
-
|
2821
|
-
|
2822
|
-
|
2823
|
-
|
2824
|
-
|
2825
|
-
|
2826
|
-
|
3021
|
+
/**
|
3022
|
+
* Concatenates an observable sequence of observable sequences.
|
3023
|
+
* @returns {Observable} An observable sequence that contains the elements of each observed inner sequence, in sequential order.
|
3024
|
+
*/
|
3025
|
+
observableProto.concatAll = function () {
|
3026
|
+
return this.merge(1);
|
3027
|
+
};
|
3028
|
+
|
3029
|
+
/** @deprecated Use `concatAll` instead. */
|
3030
|
+
observableProto.concatObservable = function () {
|
3031
|
+
deprecate('concatObservable', 'concatAll');
|
3032
|
+
return this.merge(1);
|
3033
|
+
};
|
2827
3034
|
|
2828
3035
|
/**
|
2829
3036
|
* Merges an observable sequence of observable sequences into an observable sequence, limiting the number of concurrent subscriptions to inner sequences.
|
@@ -2870,43 +3077,37 @@ if (!Array.prototype.forEach) {
|
|
2870
3077
|
activeCount === 0 && observer.onCompleted();
|
2871
3078
|
}));
|
2872
3079
|
return group;
|
2873
|
-
});
|
3080
|
+
}, sources);
|
2874
3081
|
};
|
2875
3082
|
|
2876
|
-
|
2877
|
-
|
2878
|
-
|
2879
|
-
|
2880
|
-
|
2881
|
-
|
2882
|
-
|
2883
|
-
|
2884
|
-
|
2885
|
-
|
2886
|
-
|
2887
|
-
|
2888
|
-
|
2889
|
-
|
2890
|
-
|
2891
|
-
|
2892
|
-
|
2893
|
-
|
2894
|
-
|
2895
|
-
|
2896
|
-
|
2897
|
-
|
2898
|
-
}
|
2899
|
-
if (Array.isArray(sources[0])) {
|
2900
|
-
sources = sources[0];
|
2901
|
-
}
|
2902
|
-
return observableFromArray(sources, scheduler).mergeObservable();
|
2903
|
-
};
|
3083
|
+
/**
|
3084
|
+
* Merges all the observable sequences into a single observable sequence.
|
3085
|
+
* The scheduler is optional and if not specified, the immediate scheduler is used.
|
3086
|
+
* @returns {Observable} The observable sequence that merges the elements of the observable sequences.
|
3087
|
+
*/
|
3088
|
+
var observableMerge = Observable.merge = function () {
|
3089
|
+
var scheduler, sources;
|
3090
|
+
if (!arguments[0]) {
|
3091
|
+
scheduler = immediateScheduler;
|
3092
|
+
sources = slice.call(arguments, 1);
|
3093
|
+
} else if (isScheduler(arguments[0])) {
|
3094
|
+
scheduler = arguments[0];
|
3095
|
+
sources = slice.call(arguments, 1);
|
3096
|
+
} else {
|
3097
|
+
scheduler = immediateScheduler;
|
3098
|
+
sources = slice.call(arguments, 0);
|
3099
|
+
}
|
3100
|
+
if (Array.isArray(sources[0])) {
|
3101
|
+
sources = sources[0];
|
3102
|
+
}
|
3103
|
+
return observableOf(scheduler, sources).mergeAll();
|
3104
|
+
};
|
2904
3105
|
|
2905
3106
|
/**
|
2906
3107
|
* Merges an observable sequence of observable sequences into an observable sequence.
|
2907
3108
|
* @returns {Observable} The observable sequence that merges the elements of the inner sequences.
|
2908
3109
|
*/
|
2909
|
-
observableProto.
|
3110
|
+
observableProto.mergeAll = function () {
|
2910
3111
|
var sources = this;
|
2911
3112
|
return new AnonymousObservable(function (observer) {
|
2912
3113
|
var group = new CompositeDisposable(),
|
@@ -2930,7 +3131,15 @@ if (!Array.prototype.forEach) {
|
|
2930
3131
|
group.length === 1 && observer.onCompleted();
|
2931
3132
|
}));
|
2932
3133
|
return group;
|
2933
|
-
});
|
3134
|
+
}, sources);
|
3135
|
+
};
|
3136
|
+
|
3137
|
+
/**
|
3138
|
+
* @deprecated use #mergeAll instead.
|
3139
|
+
*/
|
3140
|
+
observableProto.mergeObservable = function () {
|
3141
|
+
deprecate('mergeObservable', 'mergeAll');
|
3142
|
+
return this.mergeAll.apply(this, arguments);
|
2934
3143
|
};
|
2935
3144
|
|
2936
3145
|
/**
|
@@ -2998,7 +3207,7 @@ if (!Array.prototype.forEach) {
|
|
2998
3207
|
}));
|
2999
3208
|
|
3000
3209
|
return disposables;
|
3001
|
-
});
|
3210
|
+
}, source);
|
3002
3211
|
};
|
3003
3212
|
|
3004
3213
|
/**
|
@@ -3037,7 +3246,7 @@ if (!Array.prototype.forEach) {
|
|
3037
3246
|
!hasLatest && observer.onCompleted();
|
3038
3247
|
});
|
3039
3248
|
return new CompositeDisposable(subscription, innerSubscription);
|
3040
|
-
});
|
3249
|
+
}, sources);
|
3041
3250
|
};
|
3042
3251
|
|
3043
3252
|
/**
|
@@ -3053,7 +3262,7 @@ if (!Array.prototype.forEach) {
|
|
3053
3262
|
source.subscribe(observer),
|
3054
3263
|
other.subscribe(observer.onCompleted.bind(observer), observer.onError.bind(observer), noop)
|
3055
3264
|
);
|
3056
|
-
});
|
3265
|
+
}, source);
|
3057
3266
|
};
|
3058
3267
|
|
3059
3268
|
function zipArray(second, resultSelector) {
|
@@ -3074,7 +3283,7 @@ if (!Array.prototype.forEach) {
|
|
3074
3283
|
observer.onCompleted();
|
3075
3284
|
}
|
3076
3285
|
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
3077
|
-
});
|
3286
|
+
}, first);
|
3078
3287
|
}
|
3079
3288
|
|
3080
3289
|
/**
|
@@ -3136,7 +3345,7 @@ if (!Array.prototype.forEach) {
|
|
3136
3345
|
}
|
3137
3346
|
|
3138
3347
|
return new CompositeDisposable(subscriptions);
|
3139
|
-
});
|
3348
|
+
}, parent);
|
3140
3349
|
};
|
3141
3350
|
|
3142
3351
|
/**
|
@@ -3206,7 +3415,7 @@ if (!Array.prototype.forEach) {
|
|
3206
3415
|
* @returns {Observable} An observable sequence that hides the identity of the source sequence.
|
3207
3416
|
*/
|
3208
3417
|
observableProto.asObservable = function () {
|
3209
|
-
return new AnonymousObservable(this.subscribe.bind(this));
|
3418
|
+
return new AnonymousObservable(this.subscribe.bind(this), this);
|
3210
3419
|
};
|
3211
3420
|
|
3212
3421
|
/**
|
@@ -3230,60 +3439,58 @@ if (!Array.prototype.forEach) {
|
|
3230
3439
|
});
|
3231
3440
|
};
|
3232
3441
|
|
3233
|
-
|
3234
|
-
|
3235
|
-
|
3236
|
-
|
3237
|
-
|
3238
|
-
|
3239
|
-
|
3240
|
-
|
3241
|
-
|
3242
|
-
|
3243
|
-
});
|
3244
|
-
};
|
3442
|
+
/**
|
3443
|
+
* Dematerializes the explicit notification values of an observable sequence as implicit notifications.
|
3444
|
+
* @returns {Observable} An observable sequence exhibiting the behavior corresponding to the source sequence's notification values.
|
3445
|
+
*/
|
3446
|
+
observableProto.dematerialize = function () {
|
3447
|
+
var source = this;
|
3448
|
+
return new AnonymousObservable(function (observer) {
|
3449
|
+
return source.subscribe(function (x) { return x.accept(observer); }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
3450
|
+
}, this);
|
3451
|
+
};
|
3245
3452
|
|
3246
|
-
|
3247
|
-
|
3248
|
-
|
3249
|
-
|
3250
|
-
|
3251
|
-
|
3252
|
-
|
3253
|
-
|
3254
|
-
|
3255
|
-
|
3256
|
-
|
3257
|
-
|
3258
|
-
|
3259
|
-
|
3260
|
-
|
3261
|
-
|
3262
|
-
|
3263
|
-
|
3264
|
-
|
3265
|
-
|
3266
|
-
|
3267
|
-
|
3268
|
-
|
3269
|
-
|
3270
|
-
|
3271
|
-
|
3272
|
-
|
3273
|
-
|
3274
|
-
|
3275
|
-
|
3276
|
-
|
3277
|
-
|
3278
|
-
|
3279
|
-
|
3280
|
-
|
3281
|
-
|
3282
|
-
|
3283
|
-
|
3284
|
-
|
3285
|
-
|
3286
|
-
|
3453
|
+
/**
|
3454
|
+
* Returns an observable sequence that contains only distinct contiguous elements according to the keySelector and the comparer.
|
3455
|
+
*
|
3456
|
+
* var obs = observable.distinctUntilChanged();
|
3457
|
+
* var obs = observable.distinctUntilChanged(function (x) { return x.id; });
|
3458
|
+
* var obs = observable.distinctUntilChanged(function (x) { return x.id; }, function (x, y) { return x === y; });
|
3459
|
+
*
|
3460
|
+
* @param {Function} [keySelector] A function to compute the comparison key for each element. If not provided, it projects the value.
|
3461
|
+
* @param {Function} [comparer] Equality comparer for computed key values. If not provided, defaults to an equality comparer function.
|
3462
|
+
* @returns {Observable} An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence.
|
3463
|
+
*/
|
3464
|
+
observableProto.distinctUntilChanged = function (keySelector, comparer) {
|
3465
|
+
var source = this;
|
3466
|
+
keySelector || (keySelector = identity);
|
3467
|
+
comparer || (comparer = defaultComparer);
|
3468
|
+
return new AnonymousObservable(function (observer) {
|
3469
|
+
var hasCurrentKey = false, currentKey;
|
3470
|
+
return source.subscribe(function (value) {
|
3471
|
+
var comparerEquals = false, key;
|
3472
|
+
try {
|
3473
|
+
key = keySelector(value);
|
3474
|
+
} catch (e) {
|
3475
|
+
observer.onError(e);
|
3476
|
+
return;
|
3477
|
+
}
|
3478
|
+
if (hasCurrentKey) {
|
3479
|
+
try {
|
3480
|
+
comparerEquals = comparer(currentKey, key);
|
3481
|
+
} catch (e) {
|
3482
|
+
observer.onError(e);
|
3483
|
+
return;
|
3484
|
+
}
|
3485
|
+
}
|
3486
|
+
if (!hasCurrentKey || !comparerEquals) {
|
3487
|
+
hasCurrentKey = true;
|
3488
|
+
currentKey = key;
|
3489
|
+
observer.onNext(value);
|
3490
|
+
}
|
3491
|
+
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
3492
|
+
}, this);
|
3493
|
+
};
|
3287
3494
|
|
3288
3495
|
/**
|
3289
3496
|
* Invokes an action for each element in the observable sequence and invokes an action upon graceful or exceptional termination of the observable sequence.
|
@@ -3293,7 +3500,7 @@ if (!Array.prototype.forEach) {
|
|
3293
3500
|
* @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.
|
3294
3501
|
* @returns {Observable} The source sequence with the side-effecting behavior applied.
|
3295
3502
|
*/
|
3296
|
-
observableProto['do'] = observableProto.
|
3503
|
+
observableProto['do'] = observableProto.tap = function (observerOrOnNext, onError, onCompleted) {
|
3297
3504
|
var source = this, onNextFunc;
|
3298
3505
|
if (typeof observerOrOnNext === 'function') {
|
3299
3506
|
onNextFunc = observerOrOnNext;
|
@@ -3329,7 +3536,13 @@ if (!Array.prototype.forEach) {
|
|
3329
3536
|
}
|
3330
3537
|
observer.onCompleted();
|
3331
3538
|
});
|
3332
|
-
});
|
3539
|
+
}, this);
|
3540
|
+
};
|
3541
|
+
|
3542
|
+
/** @deprecated use #do or #tap instead. */
|
3543
|
+
observableProto.doAction = function () {
|
3544
|
+
deprecate('doAction', 'do or tap');
|
3545
|
+
return this.tap.apply(this, arguments);
|
3333
3546
|
};
|
3334
3547
|
|
3335
3548
|
/**
|
@@ -3367,13 +3580,10 @@ if (!Array.prototype.forEach) {
|
|
3367
3580
|
|
3368
3581
|
/**
|
3369
3582
|
* Invokes a specified action after the source observable sequence terminates gracefully or exceptionally.
|
3370
|
-
*
|
3371
|
-
* @example
|
3372
|
-
* var res = observable.finallyAction(function () { console.log('sequence ended'; });
|
3373
3583
|
* @param {Function} finallyAction Action to invoke after the source observable sequence terminates.
|
3374
3584
|
* @returns {Observable} Source sequence with the action-invoking termination behavior applied.
|
3375
3585
|
*/
|
3376
|
-
observableProto['finally'] = observableProto.
|
3586
|
+
observableProto['finally'] = observableProto.ensure = function (action) {
|
3377
3587
|
var source = this;
|
3378
3588
|
return new AnonymousObservable(function (observer) {
|
3379
3589
|
var subscription;
|
@@ -3392,7 +3602,15 @@ if (!Array.prototype.forEach) {
|
|
3392
3602
|
action();
|
3393
3603
|
}
|
3394
3604
|
});
|
3395
|
-
});
|
3605
|
+
}, this);
|
3606
|
+
};
|
3607
|
+
|
3608
|
+
/**
|
3609
|
+
* @deprecated use #finally or #ensure instead.
|
3610
|
+
*/
|
3611
|
+
observableProto.finallyAction = function (action) {
|
3612
|
+
deprecate('finallyAction', 'finally or ensure');
|
3613
|
+
return this.ensure(action);
|
3396
3614
|
};
|
3397
3615
|
|
3398
3616
|
/**
|
@@ -3403,7 +3621,7 @@ if (!Array.prototype.forEach) {
|
|
3403
3621
|
var source = this;
|
3404
3622
|
return new AnonymousObservable(function (observer) {
|
3405
3623
|
return source.subscribe(noop, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
3406
|
-
});
|
3624
|
+
}, source);
|
3407
3625
|
};
|
3408
3626
|
|
3409
3627
|
/**
|
@@ -3422,21 +3640,17 @@ if (!Array.prototype.forEach) {
|
|
3422
3640
|
observer.onNext(notificationCreateOnCompleted());
|
3423
3641
|
observer.onCompleted();
|
3424
3642
|
});
|
3425
|
-
});
|
3643
|
+
}, source);
|
3426
3644
|
};
|
3427
3645
|
|
3428
|
-
|
3429
|
-
|
3430
|
-
|
3431
|
-
|
3432
|
-
|
3433
|
-
|
3434
|
-
|
3435
|
-
|
3436
|
-
*/
|
3437
|
-
observableProto.repeat = function (repeatCount) {
|
3438
|
-
return enumerableRepeat(this, repeatCount).concat();
|
3439
|
-
};
|
3646
|
+
/**
|
3647
|
+
* Repeats the observable sequence a specified number of times. If the repeat count is not specified, the sequence repeats indefinitely.
|
3648
|
+
* @param {Number} [repeatCount] Number of times to repeat the sequence. If not provided, repeats the sequence indefinitely.
|
3649
|
+
* @returns {Observable} The observable sequence producing the elements of the given sequence repeatedly.
|
3650
|
+
*/
|
3651
|
+
observableProto.repeat = function (repeatCount) {
|
3652
|
+
return enumerableRepeat(this, repeatCount).concat();
|
3653
|
+
};
|
3440
3654
|
|
3441
3655
|
/**
|
3442
3656
|
* 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.
|
@@ -3449,7 +3663,7 @@ if (!Array.prototype.forEach) {
|
|
3449
3663
|
* @returns {Observable} An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.
|
3450
3664
|
*/
|
3451
3665
|
observableProto.retry = function (retryCount) {
|
3452
|
-
return enumerableRepeat(this, retryCount).
|
3666
|
+
return enumerableRepeat(this, retryCount).catchError();
|
3453
3667
|
};
|
3454
3668
|
|
3455
3669
|
/**
|
@@ -3496,7 +3710,7 @@ if (!Array.prototype.forEach) {
|
|
3496
3710
|
observer.onCompleted();
|
3497
3711
|
}
|
3498
3712
|
);
|
3499
|
-
});
|
3713
|
+
}, source);
|
3500
3714
|
};
|
3501
3715
|
|
3502
3716
|
/**
|
@@ -3515,7 +3729,7 @@ if (!Array.prototype.forEach) {
|
|
3515
3729
|
q.push(x);
|
3516
3730
|
q.length > count && observer.onNext(q.shift());
|
3517
3731
|
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
3518
|
-
});
|
3732
|
+
}, source);
|
3519
3733
|
};
|
3520
3734
|
|
3521
3735
|
/**
|
@@ -3554,10 +3768,10 @@ if (!Array.prototype.forEach) {
|
|
3554
3768
|
q.push(x);
|
3555
3769
|
q.length > count && q.shift();
|
3556
3770
|
}, observer.onError.bind(observer), function () {
|
3557
|
-
while(q.length > 0) { observer.onNext(q.shift()); }
|
3771
|
+
while (q.length > 0) { observer.onNext(q.shift()); }
|
3558
3772
|
observer.onCompleted();
|
3559
3773
|
});
|
3560
|
-
});
|
3774
|
+
}, source);
|
3561
3775
|
};
|
3562
3776
|
|
3563
3777
|
/**
|
@@ -3580,7 +3794,7 @@ if (!Array.prototype.forEach) {
|
|
3580
3794
|
observer.onNext(q);
|
3581
3795
|
observer.onCompleted();
|
3582
3796
|
});
|
3583
|
-
});
|
3797
|
+
}, source);
|
3584
3798
|
};
|
3585
3799
|
|
3586
3800
|
/**
|
@@ -3620,27 +3834,27 @@ if (!Array.prototype.forEach) {
|
|
3620
3834
|
function (x) {
|
3621
3835
|
for (var i = 0, len = q.length; i < len; i++) { q[i].onNext(x); }
|
3622
3836
|
var c = n - count + 1;
|
3623
|
-
c >=0 && c % skip === 0 && q.shift().onCompleted();
|
3837
|
+
c >= 0 && c % skip === 0 && q.shift().onCompleted();
|
3624
3838
|
++n % skip === 0 && createWindow();
|
3625
|
-
},
|
3839
|
+
},
|
3626
3840
|
function (e) {
|
3627
3841
|
while (q.length > 0) { q.shift().onError(e); }
|
3628
3842
|
observer.onError(e);
|
3629
|
-
},
|
3843
|
+
},
|
3630
3844
|
function () {
|
3631
3845
|
while (q.length > 0) { q.shift().onCompleted(); }
|
3632
3846
|
observer.onCompleted();
|
3633
3847
|
}
|
3634
3848
|
));
|
3635
3849
|
return refCountDisposable;
|
3636
|
-
});
|
3850
|
+
}, source);
|
3637
3851
|
};
|
3638
3852
|
|
3639
3853
|
function concatMap(source, selector, thisArg) {
|
3640
3854
|
return source.map(function (x, i) {
|
3641
3855
|
var result = selector.call(thisArg, x, i, source);
|
3642
3856
|
isPromise(result) && (result = observableFromPromise(result));
|
3643
|
-
(
|
3857
|
+
(isArrayLike(result) || isIterable(result)) && (result = observableFrom(result));
|
3644
3858
|
return result;
|
3645
3859
|
}).concatAll();
|
3646
3860
|
}
|
@@ -3665,18 +3879,18 @@ if (!Array.prototype.forEach) {
|
|
3665
3879
|
* @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.
|
3666
3880
|
*/
|
3667
3881
|
observableProto.selectConcat = observableProto.concatMap = function (selector, resultSelector, thisArg) {
|
3668
|
-
if (
|
3882
|
+
if (isFunction(selector) && isFunction(resultSelector)) {
|
3669
3883
|
return this.concatMap(function (x, i) {
|
3670
3884
|
var selectorResult = selector(x, i);
|
3671
3885
|
isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult));
|
3672
|
-
(
|
3886
|
+
(isArrayLike(selectorResult) || isIterable(selectorResult)) && (selectorResult = observableFrom(selectorResult));
|
3673
3887
|
|
3674
3888
|
return selectorResult.map(function (y, i2) {
|
3675
3889
|
return resultSelector(x, y, i, i2);
|
3676
3890
|
});
|
3677
3891
|
});
|
3678
3892
|
}
|
3679
|
-
return
|
3893
|
+
return isFunction(selector) ?
|
3680
3894
|
concatMap(this, selector, thisArg) :
|
3681
3895
|
concatMap(this, function () { return selector; });
|
3682
3896
|
};
|
@@ -3730,7 +3944,7 @@ if (!Array.prototype.forEach) {
|
|
3730
3944
|
observer.onNext(result);
|
3731
3945
|
observer.onCompleted();
|
3732
3946
|
});
|
3733
|
-
}).concatAll();
|
3947
|
+
}, this).concatAll();
|
3734
3948
|
};
|
3735
3949
|
|
3736
3950
|
/**
|
@@ -3744,22 +3958,18 @@ if (!Array.prototype.forEach) {
|
|
3744
3958
|
* @returns {Observable} An observable sequence that contains the specified default value if the source is empty; otherwise, the elements of the source itself.
|
3745
3959
|
*/
|
3746
3960
|
observableProto.defaultIfEmpty = function (defaultValue) {
|
3747
|
-
|
3748
|
-
|
3749
|
-
|
3750
|
-
|
3751
|
-
return
|
3752
|
-
|
3753
|
-
|
3754
|
-
|
3755
|
-
|
3756
|
-
|
3757
|
-
if (!found) {
|
3758
|
-
observer.onNext(defaultValue);
|
3759
|
-
}
|
3760
|
-
observer.onCompleted();
|
3761
|
-
});
|
3961
|
+
var source = this;
|
3962
|
+
defaultValue === undefined && (defaultValue = null);
|
3963
|
+
return new AnonymousObservable(function (observer) {
|
3964
|
+
var found = false;
|
3965
|
+
return source.subscribe(function (x) {
|
3966
|
+
found = true;
|
3967
|
+
observer.onNext(x);
|
3968
|
+
}, observer.onError.bind(observer), function () {
|
3969
|
+
!found && observer.onNext(defaultValue);
|
3970
|
+
observer.onCompleted();
|
3762
3971
|
});
|
3972
|
+
}, this);
|
3763
3973
|
};
|
3764
3974
|
|
3765
3975
|
// Swap out for Array.findIndex
|
@@ -3812,7 +4022,7 @@ if (!Array.prototype.forEach) {
|
|
3812
4022
|
},
|
3813
4023
|
observer.onError.bind(observer),
|
3814
4024
|
observer.onCompleted.bind(observer));
|
3815
|
-
});
|
4025
|
+
}, this);
|
3816
4026
|
};
|
3817
4027
|
|
3818
4028
|
/**
|
@@ -3926,30 +4136,31 @@ if (!Array.prototype.forEach) {
|
|
3926
4136
|
}));
|
3927
4137
|
|
3928
4138
|
return refCountDisposable;
|
3929
|
-
});
|
4139
|
+
}, source);
|
3930
4140
|
};
|
3931
4141
|
|
3932
4142
|
/**
|
3933
|
-
*
|
4143
|
+
* Projects each element of an observable sequence into a new form by incorporating the element's index.
|
3934
4144
|
* @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.
|
3935
4145
|
* @param {Any} [thisArg] Object to use as this when executing callback.
|
3936
4146
|
* @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source.
|
3937
4147
|
*/
|
3938
4148
|
observableProto.select = observableProto.map = function (selector, thisArg) {
|
3939
|
-
var
|
4149
|
+
var selectorFn = isFunction(selector) ? selector : function () { return selector; },
|
4150
|
+
source = this;
|
3940
4151
|
return new AnonymousObservable(function (observer) {
|
3941
4152
|
var count = 0;
|
3942
|
-
return
|
4153
|
+
return source.subscribe(function (value) {
|
3943
4154
|
var result;
|
3944
4155
|
try {
|
3945
|
-
result =
|
4156
|
+
result = selectorFn.call(thisArg, value, count++, source);
|
3946
4157
|
} catch (e) {
|
3947
4158
|
observer.onError(e);
|
3948
4159
|
return;
|
3949
4160
|
}
|
3950
4161
|
observer.onNext(result);
|
3951
4162
|
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
3952
|
-
});
|
4163
|
+
}, source);
|
3953
4164
|
};
|
3954
4165
|
|
3955
4166
|
/**
|
@@ -3965,9 +4176,9 @@ if (!Array.prototype.forEach) {
|
|
3965
4176
|
return source.map(function (x, i) {
|
3966
4177
|
var result = selector.call(thisArg, x, i, source);
|
3967
4178
|
isPromise(result) && (result = observableFromPromise(result));
|
3968
|
-
(
|
4179
|
+
(isArrayLike(result) || isIterable(result)) && (result = observableFrom(result));
|
3969
4180
|
return result;
|
3970
|
-
}).
|
4181
|
+
}).mergeAll();
|
3971
4182
|
}
|
3972
4183
|
|
3973
4184
|
/**
|
@@ -3990,18 +4201,18 @@ if (!Array.prototype.forEach) {
|
|
3990
4201
|
* @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.
|
3991
4202
|
*/
|
3992
4203
|
observableProto.selectMany = observableProto.flatMap = function (selector, resultSelector, thisArg) {
|
3993
|
-
if (
|
4204
|
+
if (isFunction(selector) && isFunction(resultSelector)) {
|
3994
4205
|
return this.flatMap(function (x, i) {
|
3995
4206
|
var selectorResult = selector(x, i);
|
3996
4207
|
isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult));
|
3997
|
-
(
|
4208
|
+
(isArrayLike(selectorResult) || isIterable(selectorResult)) && (selectorResult = observableFrom(selectorResult));
|
3998
4209
|
|
3999
4210
|
return selectorResult.map(function (y, i2) {
|
4000
4211
|
return resultSelector(x, y, i, i2);
|
4001
4212
|
});
|
4002
4213
|
}, thisArg);
|
4003
4214
|
}
|
4004
|
-
return
|
4215
|
+
return isFunction(selector) ?
|
4005
4216
|
flatMap(this, selector, thisArg) :
|
4006
4217
|
flatMap(this, function () { return selector; });
|
4007
4218
|
};
|
@@ -4055,7 +4266,7 @@ if (!Array.prototype.forEach) {
|
|
4055
4266
|
observer.onNext(result);
|
4056
4267
|
observer.onCompleted();
|
4057
4268
|
});
|
4058
|
-
}).mergeAll();
|
4269
|
+
}, source).mergeAll();
|
4059
4270
|
};
|
4060
4271
|
|
4061
4272
|
/**
|
@@ -4076,18 +4287,18 @@ if (!Array.prototype.forEach) {
|
|
4076
4287
|
* @returns {Observable} An observable sequence that contains the elements that occur after the specified index in the input sequence.
|
4077
4288
|
*/
|
4078
4289
|
observableProto.skip = function (count) {
|
4079
|
-
|
4080
|
-
|
4081
|
-
|
4082
|
-
|
4083
|
-
|
4084
|
-
|
4085
|
-
|
4086
|
-
|
4087
|
-
|
4088
|
-
|
4089
|
-
|
4090
|
-
|
4290
|
+
if (count < 0) { throw new Error(argumentOutOfRange); }
|
4291
|
+
var source = this;
|
4292
|
+
return new AnonymousObservable(function (observer) {
|
4293
|
+
var remaining = count;
|
4294
|
+
return source.subscribe(function (x) {
|
4295
|
+
if (remaining <= 0) {
|
4296
|
+
observer.onNext(x);
|
4297
|
+
} else {
|
4298
|
+
remaining--;
|
4299
|
+
}
|
4300
|
+
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
4301
|
+
}, source);
|
4091
4302
|
};
|
4092
4303
|
|
4093
4304
|
/**
|
@@ -4115,7 +4326,7 @@ if (!Array.prototype.forEach) {
|
|
4115
4326
|
}
|
4116
4327
|
running && observer.onNext(x);
|
4117
4328
|
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
4118
|
-
});
|
4329
|
+
}, source);
|
4119
4330
|
};
|
4120
4331
|
|
4121
4332
|
/**
|
@@ -4128,18 +4339,18 @@ if (!Array.prototype.forEach) {
|
|
4128
4339
|
* @returns {Observable} An observable sequence that contains the specified number of elements from the start of the input sequence.
|
4129
4340
|
*/
|
4130
4341
|
observableProto.take = function (count, scheduler) {
|
4131
|
-
|
4132
|
-
|
4133
|
-
|
4134
|
-
|
4135
|
-
|
4136
|
-
|
4137
|
-
|
4138
|
-
|
4139
|
-
|
4140
|
-
|
4141
|
-
|
4142
|
-
|
4342
|
+
if (count < 0) { throw new RangeError(argumentOutOfRange); }
|
4343
|
+
if (count === 0) { return observableEmpty(scheduler); }
|
4344
|
+
var source = this;
|
4345
|
+
return new AnonymousObservable(function (observer) {
|
4346
|
+
var remaining = count;
|
4347
|
+
return source.subscribe(function (x) {
|
4348
|
+
if (remaining-- > 0) {
|
4349
|
+
observer.onNext(x);
|
4350
|
+
remaining === 0 && observer.onCompleted();
|
4351
|
+
}
|
4352
|
+
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
4353
|
+
}, source);
|
4143
4354
|
};
|
4144
4355
|
|
4145
4356
|
/**
|
@@ -4150,13 +4361,13 @@ if (!Array.prototype.forEach) {
|
|
4150
4361
|
* @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.
|
4151
4362
|
*/
|
4152
4363
|
observableProto.takeWhile = function (predicate, thisArg) {
|
4153
|
-
var
|
4364
|
+
var source = this;
|
4154
4365
|
return new AnonymousObservable(function (observer) {
|
4155
4366
|
var i = 0, running = true;
|
4156
|
-
return
|
4367
|
+
return source.subscribe(function (x) {
|
4157
4368
|
if (running) {
|
4158
4369
|
try {
|
4159
|
-
running = predicate.call(thisArg, x, i++,
|
4370
|
+
running = predicate.call(thisArg, x, i++, source);
|
4160
4371
|
} catch (e) {
|
4161
4372
|
observer.onError(e);
|
4162
4373
|
return;
|
@@ -4168,7 +4379,7 @@ if (!Array.prototype.forEach) {
|
|
4168
4379
|
}
|
4169
4380
|
}
|
4170
4381
|
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
4171
|
-
});
|
4382
|
+
}, source);
|
4172
4383
|
};
|
4173
4384
|
|
4174
4385
|
/**
|
@@ -4182,20 +4393,20 @@ if (!Array.prototype.forEach) {
|
|
4182
4393
|
* @returns {Observable} An observable sequence that contains elements from the input sequence that satisfy the condition.
|
4183
4394
|
*/
|
4184
4395
|
observableProto.where = observableProto.filter = function (predicate, thisArg) {
|
4185
|
-
|
4186
|
-
|
4187
|
-
|
4188
|
-
|
4189
|
-
|
4190
|
-
|
4191
|
-
|
4192
|
-
|
4193
|
-
|
4194
|
-
|
4195
|
-
|
4196
|
-
|
4197
|
-
|
4198
|
-
|
4396
|
+
var source = this;
|
4397
|
+
return new AnonymousObservable(function (observer) {
|
4398
|
+
var count = 0;
|
4399
|
+
return source.subscribe(function (value) {
|
4400
|
+
var shouldRun;
|
4401
|
+
try {
|
4402
|
+
shouldRun = predicate.call(thisArg, value, count++, parent);
|
4403
|
+
} catch (e) {
|
4404
|
+
observer.onError(e);
|
4405
|
+
return;
|
4406
|
+
}
|
4407
|
+
shouldRun && observer.onNext(value);
|
4408
|
+
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
4409
|
+
}, source);
|
4199
4410
|
};
|
4200
4411
|
|
4201
4412
|
observableProto.finalValue = function () {
|
@@ -4213,7 +4424,7 @@ if (!Array.prototype.forEach) {
|
|
4213
4424
|
observer.onCompleted();
|
4214
4425
|
}
|
4215
4426
|
});
|
4216
|
-
});
|
4427
|
+
}, source);
|
4217
4428
|
};
|
4218
4429
|
|
4219
4430
|
function extremaBy(source, keySelector, comparer) {
|
@@ -4248,24 +4459,24 @@ if (!Array.prototype.forEach) {
|
|
4248
4459
|
observer.onNext(list);
|
4249
4460
|
observer.onCompleted();
|
4250
4461
|
});
|
4251
|
-
});
|
4462
|
+
}, source);
|
4252
4463
|
}
|
4253
4464
|
|
4254
|
-
|
4255
|
-
|
4256
|
-
|
4257
|
-
|
4258
|
-
return x[0];
|
4259
|
-
}
|
4465
|
+
function firstOnly(x) {
|
4466
|
+
if (x.length === 0) { throw new Error(sequenceContainsNoElements); }
|
4467
|
+
return x[0];
|
4468
|
+
}
|
4260
4469
|
|
4261
4470
|
/**
|
4262
4471
|
* Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value.
|
4263
4472
|
* For aggregation behavior with incremental intermediate results, see Observable.scan.
|
4473
|
+
* @deprecated Use #reduce instead
|
4264
4474
|
* @param {Mixed} [seed] The initial accumulator value.
|
4265
4475
|
* @param {Function} accumulator An accumulator function to be invoked on each element.
|
4266
4476
|
* @returns {Observable} An observable sequence containing a single element with the final accumulator value.
|
4267
4477
|
*/
|
4268
4478
|
observableProto.aggregate = function () {
|
4479
|
+
deprecate('aggregate', 'reduce');
|
4269
4480
|
var seed, hasSeed, accumulator;
|
4270
4481
|
if (arguments.length === 2) {
|
4271
4482
|
seed = arguments[0];
|
@@ -4293,28 +4504,31 @@ if (!Array.prototype.forEach) {
|
|
4293
4504
|
return hasSeed ? this.scan(seed, accumulator).startWith(seed).finalValue() : this.scan(accumulator).finalValue();
|
4294
4505
|
};
|
4295
4506
|
|
4296
|
-
|
4297
|
-
|
4298
|
-
|
4299
|
-
|
4300
|
-
|
4301
|
-
|
4302
|
-
|
4303
|
-
|
4304
|
-
|
4305
|
-
|
4306
|
-
return
|
4307
|
-
|
4308
|
-
|
4309
|
-
|
4310
|
-
|
4311
|
-
|
4312
|
-
|
4313
|
-
|
4314
|
-
|
4315
|
-
|
4316
|
-
|
4317
|
-
|
4507
|
+
/**
|
4508
|
+
* Determines whether any element of an observable sequence satisfies a condition if present, else if any items are in the sequence.
|
4509
|
+
* @param {Function} [predicate] A function to test each element for a condition.
|
4510
|
+
* @returns {Observable} An observable sequence containing a single element determining whether any elements in the source sequence pass the test in the specified predicate if given, else if any items are in the sequence.
|
4511
|
+
*/
|
4512
|
+
observableProto.some = function (predicate, thisArg) {
|
4513
|
+
var source = this;
|
4514
|
+
return predicate ?
|
4515
|
+
source.filter(predicate, thisArg).some() :
|
4516
|
+
new AnonymousObservable(function (observer) {
|
4517
|
+
return source.subscribe(function () {
|
4518
|
+
observer.onNext(true);
|
4519
|
+
observer.onCompleted();
|
4520
|
+
}, observer.onError.bind(observer), function () {
|
4521
|
+
observer.onNext(false);
|
4522
|
+
observer.onCompleted();
|
4523
|
+
});
|
4524
|
+
}, source);
|
4525
|
+
};
|
4526
|
+
|
4527
|
+
/** @deprecated use #some instead */
|
4528
|
+
observableProto.any = function () {
|
4529
|
+
deprecate('any', 'some');
|
4530
|
+
return this.some.apply(this, arguments);
|
4531
|
+
};
|
4318
4532
|
|
4319
4533
|
/**
|
4320
4534
|
* Determines whether an observable sequence is empty.
|
@@ -4324,22 +4538,21 @@ if (!Array.prototype.forEach) {
|
|
4324
4538
|
return this.any().map(not);
|
4325
4539
|
};
|
4326
4540
|
|
4327
|
-
|
4328
|
-
|
4329
|
-
|
4330
|
-
|
4331
|
-
|
4332
|
-
|
4333
|
-
|
4334
|
-
|
4335
|
-
|
4336
|
-
|
4337
|
-
|
4338
|
-
|
4339
|
-
|
4340
|
-
|
4341
|
-
|
4342
|
-
};
|
4541
|
+
/**
|
4542
|
+
* Determines whether all elements of an observable sequence satisfy a condition.
|
4543
|
+
* @param {Function} [predicate] A function to test each element for a condition.
|
4544
|
+
* @param {Any} [thisArg] Object to use as this when executing callback.
|
4545
|
+
* @returns {Observable} An observable sequence containing a single element determining whether all elements in the source sequence pass the test in the specified predicate.
|
4546
|
+
*/
|
4547
|
+
observableProto.every = function (predicate, thisArg) {
|
4548
|
+
return this.filter(function (v) { return !predicate(v); }, thisArg).some().map(not);
|
4549
|
+
};
|
4550
|
+
|
4551
|
+
/** @deprecated use #every instead */
|
4552
|
+
observableProto.all = function () {
|
4553
|
+
deprecate('all', 'every');
|
4554
|
+
return this.every.apply(this, arguments);
|
4555
|
+
};
|
4343
4556
|
|
4344
4557
|
/**
|
4345
4558
|
* Determines whether an observable sequence contains a specified element with an optional equality comparer.
|
@@ -4372,7 +4585,7 @@ if (!Array.prototype.forEach) {
|
|
4372
4585
|
observer.onNext(false);
|
4373
4586
|
observer.onCompleted();
|
4374
4587
|
});
|
4375
|
-
});
|
4588
|
+
}, this);
|
4376
4589
|
};
|
4377
4590
|
|
4378
4591
|
/**
|
@@ -4421,13 +4634,11 @@ if (!Array.prototype.forEach) {
|
|
4421
4634
|
observer.onNext(-1);
|
4422
4635
|
observer.onCompleted();
|
4423
4636
|
});
|
4424
|
-
});
|
4637
|
+
}, source);
|
4425
4638
|
};
|
4639
|
+
|
4426
4640
|
/**
|
4427
4641
|
* Computes the sum of a sequence of values that are obtained by invoking an optional transform function on each element of the input sequence, else if not specified computes the sum on each item in the sequence.
|
4428
|
-
* @example
|
4429
|
-
* var res = source.sum();
|
4430
|
-
* var res = source.sum(function (x) { return x.value; });
|
4431
4642
|
* @param {Function} [selector] A transform function to apply to each element.
|
4432
4643
|
* @param {Any} [thisArg] Object to use as this when executing callback.
|
4433
4644
|
* @returns {Observable} An observable sequence containing a single element with the sum of the values in the source sequence.
|
@@ -4435,68 +4646,62 @@ if (!Array.prototype.forEach) {
|
|
4435
4646
|
observableProto.sum = function (keySelector, thisArg) {
|
4436
4647
|
return keySelector && isFunction(keySelector) ?
|
4437
4648
|
this.map(keySelector, thisArg).sum() :
|
4438
|
-
this.
|
4649
|
+
this.reduce(function (prev, curr) {
|
4439
4650
|
return prev + curr;
|
4440
|
-
});
|
4651
|
+
}, 0);
|
4441
4652
|
};
|
4442
4653
|
|
4443
|
-
|
4444
|
-
|
4445
|
-
|
4446
|
-
|
4447
|
-
|
4448
|
-
|
4449
|
-
|
4450
|
-
|
4451
|
-
|
4452
|
-
|
4453
|
-
|
4454
|
-
|
4455
|
-
|
4456
|
-
});
|
4457
|
-
};
|
4654
|
+
/**
|
4655
|
+
* Returns the elements in an observable sequence with the minimum key value according to the specified comparer.
|
4656
|
+
* @example
|
4657
|
+
* var res = source.minBy(function (x) { return x.value; });
|
4658
|
+
* var res = source.minBy(function (x) { return x.value; }, function (x, y) { return x - y; });
|
4659
|
+
* @param {Function} keySelector Key selector function.
|
4660
|
+
* @param {Function} [comparer] Comparer used to compare key values.
|
4661
|
+
* @returns {Observable} An observable sequence containing a list of zero or more elements that have a minimum key value.
|
4662
|
+
*/
|
4663
|
+
observableProto.minBy = function (keySelector, comparer) {
|
4664
|
+
comparer || (comparer = defaultSubComparer);
|
4665
|
+
return extremaBy(this, keySelector, function (x, y) { return comparer(x, y) * -1; });
|
4666
|
+
};
|
4458
4667
|
|
4459
|
-
|
4460
|
-
|
4461
|
-
|
4462
|
-
|
4463
|
-
|
4464
|
-
|
4465
|
-
|
4466
|
-
|
4467
|
-
|
4468
|
-
|
4469
|
-
|
4470
|
-
});
|
4471
|
-
};
|
4668
|
+
/**
|
4669
|
+
* Returns the minimum element in an observable sequence according to the optional comparer else a default greater than less than check.
|
4670
|
+
* @example
|
4671
|
+
* var res = source.min();
|
4672
|
+
* var res = source.min(function (x, y) { return x.value - y.value; });
|
4673
|
+
* @param {Function} [comparer] Comparer used to compare elements.
|
4674
|
+
* @returns {Observable} An observable sequence containing a single element with the minimum element in the source sequence.
|
4675
|
+
*/
|
4676
|
+
observableProto.min = function (comparer) {
|
4677
|
+
return this.minBy(identity, comparer).map(function (x) { return firstOnly(x); });
|
4678
|
+
};
|
4472
4679
|
|
4473
|
-
|
4474
|
-
|
4475
|
-
|
4476
|
-
|
4477
|
-
|
4478
|
-
|
4479
|
-
|
4480
|
-
|
4481
|
-
|
4482
|
-
|
4483
|
-
|
4484
|
-
|
4485
|
-
|
4680
|
+
/**
|
4681
|
+
* Returns the elements in an observable sequence with the maximum key value according to the specified comparer.
|
4682
|
+
* @example
|
4683
|
+
* var res = source.maxBy(function (x) { return x.value; });
|
4684
|
+
* var res = source.maxBy(function (x) { return x.value; }, function (x, y) { return x - y;; });
|
4685
|
+
* @param {Function} keySelector Key selector function.
|
4686
|
+
* @param {Function} [comparer] Comparer used to compare key values.
|
4687
|
+
* @returns {Observable} An observable sequence containing a list of zero or more elements that have a maximum key value.
|
4688
|
+
*/
|
4689
|
+
observableProto.maxBy = function (keySelector, comparer) {
|
4690
|
+
comparer || (comparer = defaultSubComparer);
|
4691
|
+
return extremaBy(this, keySelector, comparer);
|
4692
|
+
};
|
4486
4693
|
|
4487
|
-
|
4488
|
-
|
4489
|
-
|
4490
|
-
|
4491
|
-
|
4492
|
-
|
4493
|
-
|
4494
|
-
|
4495
|
-
|
4496
|
-
|
4497
|
-
|
4498
|
-
});
|
4499
|
-
};
|
4694
|
+
/**
|
4695
|
+
* Returns the maximum value in an observable sequence according to the specified comparer.
|
4696
|
+
* @example
|
4697
|
+
* var res = source.max();
|
4698
|
+
* var res = source.max(function (x, y) { return x.value - y.value; });
|
4699
|
+
* @param {Function} [comparer] Comparer used to compare elements.
|
4700
|
+
* @returns {Observable} An observable sequence containing a single element with the maximum element in the source sequence.
|
4701
|
+
*/
|
4702
|
+
observableProto.max = function (comparer) {
|
4703
|
+
return this.maxBy(identity, comparer).map(function (x) { return firstOnly(x); });
|
4704
|
+
};
|
4500
4705
|
|
4501
4706
|
/**
|
4502
4707
|
* Computes the average of an observable sequence of values that are in the sequence or obtained by invoking a transform function on each element of the input sequence if present.
|
@@ -4520,28 +4725,6 @@ if (!Array.prototype.forEach) {
|
|
4520
4725
|
});
|
4521
4726
|
};
|
4522
4727
|
|
4523
|
-
function sequenceEqualArray(first, second, comparer) {
|
4524
|
-
return new AnonymousObservable(function (observer) {
|
4525
|
-
var count = 0, len = second.length;
|
4526
|
-
return first.subscribe(function (value) {
|
4527
|
-
var equal = false;
|
4528
|
-
try {
|
4529
|
-
count < len && (equal = comparer(value, second[count++]));
|
4530
|
-
} catch (e) {
|
4531
|
-
observer.onError(e);
|
4532
|
-
return;
|
4533
|
-
}
|
4534
|
-
if (!equal) {
|
4535
|
-
observer.onNext(false);
|
4536
|
-
observer.onCompleted();
|
4537
|
-
}
|
4538
|
-
}, observer.onError.bind(observer), function () {
|
4539
|
-
observer.onNext(count === len);
|
4540
|
-
observer.onCompleted();
|
4541
|
-
});
|
4542
|
-
});
|
4543
|
-
}
|
4544
|
-
|
4545
4728
|
/**
|
4546
4729
|
* Determines whether two sequences are equal by comparing the elements pairwise using a specified equality comparer.
|
4547
4730
|
*
|
@@ -4557,9 +4740,6 @@ if (!Array.prototype.forEach) {
|
|
4557
4740
|
observableProto.sequenceEqual = function (second, comparer) {
|
4558
4741
|
var first = this;
|
4559
4742
|
comparer || (comparer = defaultComparer);
|
4560
|
-
if (Array.isArray(second)) {
|
4561
|
-
return sequenceEqualArray(first, second, comparer);
|
4562
|
-
}
|
4563
4743
|
return new AnonymousObservable(function (observer) {
|
4564
4744
|
var donel = false, doner = false, ql = [], qr = [];
|
4565
4745
|
var subscription1 = first.subscribe(function (x) {
|
@@ -4595,6 +4775,7 @@ if (!Array.prototype.forEach) {
|
|
4595
4775
|
}
|
4596
4776
|
});
|
4597
4777
|
|
4778
|
+
(isArrayLike(second) || isIterable(second)) && (second = observableFrom(second));
|
4598
4779
|
isPromise(second) && (second = observableFromPromise(second));
|
4599
4780
|
var subscription2 = second.subscribe(function (x) {
|
4600
4781
|
var equal;
|
@@ -4629,55 +4810,52 @@ if (!Array.prototype.forEach) {
|
|
4629
4810
|
}
|
4630
4811
|
});
|
4631
4812
|
return new CompositeDisposable(subscription1, subscription2);
|
4632
|
-
});
|
4813
|
+
}, first);
|
4633
4814
|
};
|
4634
4815
|
|
4635
|
-
|
4636
|
-
|
4637
|
-
|
4816
|
+
function elementAtOrDefault(source, index, hasDefault, defaultValue) {
|
4817
|
+
if (index < 0) { throw new Error(argumentOutOfRange); }
|
4818
|
+
return new AnonymousObservable(function (observer) {
|
4819
|
+
var i = index;
|
4820
|
+
return source.subscribe(function (x) {
|
4821
|
+
if (i-- === 0) {
|
4822
|
+
observer.onNext(x);
|
4823
|
+
observer.onCompleted();
|
4638
4824
|
}
|
4639
|
-
|
4640
|
-
|
4641
|
-
|
4642
|
-
|
4643
|
-
|
4644
|
-
|
4645
|
-
|
4646
|
-
|
4647
|
-
|
4648
|
-
|
4649
|
-
observer.onError(new Error(argumentOutOfRange));
|
4650
|
-
} else {
|
4651
|
-
observer.onNext(defaultValue);
|
4652
|
-
observer.onCompleted();
|
4653
|
-
}
|
4654
|
-
});
|
4655
|
-
});
|
4656
|
-
}
|
4825
|
+
}, observer.onError.bind(observer), function () {
|
4826
|
+
if (!hasDefault) {
|
4827
|
+
observer.onError(new Error(argumentOutOfRange));
|
4828
|
+
} else {
|
4829
|
+
observer.onNext(defaultValue);
|
4830
|
+
observer.onCompleted();
|
4831
|
+
}
|
4832
|
+
});
|
4833
|
+
}, source);
|
4834
|
+
}
|
4657
4835
|
|
4658
|
-
|
4659
|
-
|
4660
|
-
|
4661
|
-
|
4662
|
-
|
4663
|
-
|
4664
|
-
|
4665
|
-
|
4666
|
-
|
4667
|
-
|
4836
|
+
/**
|
4837
|
+
* Returns the element at a specified index in a sequence.
|
4838
|
+
* @example
|
4839
|
+
* var res = source.elementAt(5);
|
4840
|
+
* @param {Number} index The zero-based index of the element to retrieve.
|
4841
|
+
* @returns {Observable} An observable sequence that produces the element at the specified position in the source sequence.
|
4842
|
+
*/
|
4843
|
+
observableProto.elementAt = function (index) {
|
4844
|
+
return elementAtOrDefault(this, index, false);
|
4845
|
+
};
|
4668
4846
|
|
4669
|
-
|
4670
|
-
|
4671
|
-
|
4672
|
-
|
4673
|
-
|
4674
|
-
|
4675
|
-
|
4676
|
-
|
4677
|
-
|
4678
|
-
|
4679
|
-
|
4680
|
-
|
4847
|
+
/**
|
4848
|
+
* Returns the element at a specified index in a sequence or a default value if the index is out of range.
|
4849
|
+
* @example
|
4850
|
+
* var res = source.elementAtOrDefault(5);
|
4851
|
+
* var res = source.elementAtOrDefault(5, 0);
|
4852
|
+
* @param {Number} index The zero-based index of the element to retrieve.
|
4853
|
+
* @param [defaultValue] The default value if the index is outside the bounds of the source sequence.
|
4854
|
+
* @returns {Observable} An observable sequence that produces the element at the specified position in the source sequence, or a default value if the index is outside the bounds of the source sequence.
|
4855
|
+
*/
|
4856
|
+
observableProto.elementAtOrDefault = function (index, defaultValue) {
|
4857
|
+
return elementAtOrDefault(this, index, true, defaultValue);
|
4858
|
+
};
|
4681
4859
|
|
4682
4860
|
function singleOrDefaultAsync(source, hasDefault, defaultValue) {
|
4683
4861
|
return new AnonymousObservable(function (observer) {
|
@@ -4697,14 +4875,11 @@ if (!Array.prototype.forEach) {
|
|
4697
4875
|
observer.onCompleted();
|
4698
4876
|
}
|
4699
4877
|
});
|
4700
|
-
});
|
4878
|
+
}, source);
|
4701
4879
|
}
|
4702
4880
|
|
4703
4881
|
/**
|
4704
4882
|
* Returns the only element of an observable sequence that satisfies the condition in the optional predicate, and reports an exception if there is not exactly one element in the observable sequence.
|
4705
|
-
* @example
|
4706
|
-
* var res = res = source.single();
|
4707
|
-
* var res = res = source.single(function (x) { return x === 42; });
|
4708
4883
|
* @param {Function} [predicate] A predicate function to evaluate for elements in the source sequence.
|
4709
4884
|
* @param {Any} [thisArg] Object to use as `this` when executing the predicate.
|
4710
4885
|
* @returns {Observable} Sequence containing the single element in the observable sequence that satisfies the condition in the predicate.
|
@@ -4734,211 +4909,198 @@ if (!Array.prototype.forEach) {
|
|
4734
4909
|
singleOrDefaultAsync(this, true, defaultValue);
|
4735
4910
|
};
|
4736
4911
|
|
4737
|
-
|
4738
|
-
|
4739
|
-
|
4740
|
-
|
4741
|
-
|
4742
|
-
|
4743
|
-
|
4744
|
-
|
4745
|
-
|
4746
|
-
|
4747
|
-
|
4748
|
-
|
4749
|
-
|
4750
|
-
|
4751
|
-
|
4912
|
+
function firstOrDefaultAsync(source, hasDefault, defaultValue) {
|
4913
|
+
return new AnonymousObservable(function (observer) {
|
4914
|
+
return source.subscribe(function (x) {
|
4915
|
+
observer.onNext(x);
|
4916
|
+
observer.onCompleted();
|
4917
|
+
}, observer.onError.bind(observer), function () {
|
4918
|
+
if (!hasDefault) {
|
4919
|
+
observer.onError(new Error(sequenceContainsNoElements));
|
4920
|
+
} else {
|
4921
|
+
observer.onNext(defaultValue);
|
4922
|
+
observer.onCompleted();
|
4923
|
+
}
|
4924
|
+
});
|
4925
|
+
}, source);
|
4926
|
+
}
|
4752
4927
|
|
4753
|
-
|
4754
|
-
|
4755
|
-
|
4756
|
-
|
4757
|
-
|
4758
|
-
|
4759
|
-
|
4760
|
-
|
4761
|
-
|
4762
|
-
|
4763
|
-
|
4764
|
-
|
4765
|
-
|
4766
|
-
|
4928
|
+
/**
|
4929
|
+
* Returns the first element of an observable sequence that satisfies the condition in the predicate if present else the first item in the sequence.
|
4930
|
+
* @example
|
4931
|
+
* var res = res = source.first();
|
4932
|
+
* var res = res = source.first(function (x) { return x > 3; });
|
4933
|
+
* @param {Function} [predicate] A predicate function to evaluate for elements in the source sequence.
|
4934
|
+
* @param {Any} [thisArg] Object to use as `this` when executing the predicate.
|
4935
|
+
* @returns {Observable} Sequence containing the first element in the observable sequence that satisfies the condition in the predicate if provided, else the first item in the sequence.
|
4936
|
+
*/
|
4937
|
+
observableProto.first = function (predicate, thisArg) {
|
4938
|
+
return predicate ?
|
4939
|
+
this.where(predicate, thisArg).first() :
|
4940
|
+
firstOrDefaultAsync(this, false);
|
4941
|
+
};
|
4767
4942
|
|
4768
|
-
|
4769
|
-
|
4770
|
-
|
4771
|
-
|
4772
|
-
|
4773
|
-
|
4774
|
-
|
4775
|
-
|
4776
|
-
|
4777
|
-
|
4778
|
-
|
4779
|
-
|
4780
|
-
observableProto.firstOrDefault = function (predicate, defaultValue, thisArg) {
|
4781
|
-
return predicate ?
|
4782
|
-
this.where(predicate).firstOrDefault(null, defaultValue) :
|
4783
|
-
firstOrDefaultAsync(this, true, defaultValue);
|
4784
|
-
};
|
4943
|
+
/**
|
4944
|
+
* Returns the first element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.
|
4945
|
+
* @param {Function} [predicate] A predicate function to evaluate for elements in the source sequence.
|
4946
|
+
* @param {Any} [defaultValue] The default value if no such element exists. If not specified, defaults to null.
|
4947
|
+
* @param {Any} [thisArg] Object to use as `this` when executing the predicate.
|
4948
|
+
* @returns {Observable} Sequence containing the first element in the observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.
|
4949
|
+
*/
|
4950
|
+
observableProto.firstOrDefault = function (predicate, defaultValue, thisArg) {
|
4951
|
+
return predicate ?
|
4952
|
+
this.where(predicate).firstOrDefault(null, defaultValue) :
|
4953
|
+
firstOrDefaultAsync(this, true, defaultValue);
|
4954
|
+
};
|
4785
4955
|
|
4786
|
-
|
4787
|
-
|
4788
|
-
|
4789
|
-
|
4790
|
-
|
4791
|
-
|
4792
|
-
|
4793
|
-
|
4794
|
-
|
4795
|
-
|
4796
|
-
|
4797
|
-
|
4798
|
-
|
4799
|
-
|
4800
|
-
|
4801
|
-
|
4956
|
+
function lastOrDefaultAsync(source, hasDefault, defaultValue) {
|
4957
|
+
return new AnonymousObservable(function (observer) {
|
4958
|
+
var value = defaultValue, seenValue = false;
|
4959
|
+
return source.subscribe(function (x) {
|
4960
|
+
value = x;
|
4961
|
+
seenValue = true;
|
4962
|
+
}, observer.onError.bind(observer), function () {
|
4963
|
+
if (!seenValue && !hasDefault) {
|
4964
|
+
observer.onError(new Error(sequenceContainsNoElements));
|
4965
|
+
} else {
|
4966
|
+
observer.onNext(value);
|
4967
|
+
observer.onCompleted();
|
4968
|
+
}
|
4969
|
+
});
|
4970
|
+
}, source);
|
4971
|
+
}
|
4802
4972
|
|
4803
|
-
|
4804
|
-
|
4805
|
-
|
4806
|
-
|
4807
|
-
|
4808
|
-
|
4809
|
-
|
4810
|
-
|
4811
|
-
|
4812
|
-
|
4813
|
-
|
4814
|
-
this.where(predicate, thisArg).last() :
|
4815
|
-
lastOrDefaultAsync(this, false);
|
4816
|
-
};
|
4973
|
+
/**
|
4974
|
+
* Returns the last element of an observable sequence that satisfies the condition in the predicate if specified, else the last element.
|
4975
|
+
* @param {Function} [predicate] A predicate function to evaluate for elements in the source sequence.
|
4976
|
+
* @param {Any} [thisArg] Object to use as `this` when executing the predicate.
|
4977
|
+
* @returns {Observable} Sequence containing the last element in the observable sequence that satisfies the condition in the predicate.
|
4978
|
+
*/
|
4979
|
+
observableProto.last = function (predicate, thisArg) {
|
4980
|
+
return predicate ?
|
4981
|
+
this.where(predicate, thisArg).last() :
|
4982
|
+
lastOrDefaultAsync(this, false);
|
4983
|
+
};
|
4817
4984
|
|
4818
|
-
|
4819
|
-
|
4820
|
-
|
4821
|
-
|
4822
|
-
|
4823
|
-
|
4824
|
-
|
4825
|
-
|
4826
|
-
|
4827
|
-
|
4828
|
-
|
4829
|
-
|
4830
|
-
observableProto.lastOrDefault = function (predicate, defaultValue, thisArg) {
|
4831
|
-
return predicate ?
|
4832
|
-
this.where(predicate, thisArg).lastOrDefault(null, defaultValue) :
|
4833
|
-
lastOrDefaultAsync(this, true, defaultValue);
|
4834
|
-
};
|
4985
|
+
/**
|
4986
|
+
* Returns the last element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.
|
4987
|
+
* @param {Function} [predicate] A predicate function to evaluate for elements in the source sequence.
|
4988
|
+
* @param [defaultValue] The default value if no such element exists. If not specified, defaults to null.
|
4989
|
+
* @param {Any} [thisArg] Object to use as `this` when executing the predicate.
|
4990
|
+
* @returns {Observable} Sequence containing the last element in the observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.
|
4991
|
+
*/
|
4992
|
+
observableProto.lastOrDefault = function (predicate, defaultValue, thisArg) {
|
4993
|
+
return predicate ?
|
4994
|
+
this.where(predicate, thisArg).lastOrDefault(null, defaultValue) :
|
4995
|
+
lastOrDefaultAsync(this, true, defaultValue);
|
4996
|
+
};
|
4835
4997
|
|
4836
|
-
|
4837
|
-
|
4838
|
-
|
4839
|
-
|
4840
|
-
|
4841
|
-
|
4842
|
-
|
4843
|
-
|
4844
|
-
|
4845
|
-
|
4846
|
-
|
4847
|
-
|
4848
|
-
|
4849
|
-
|
4850
|
-
|
4851
|
-
|
4852
|
-
|
4853
|
-
|
4854
|
-
|
4855
|
-
|
4856
|
-
|
4857
|
-
|
4858
|
-
|
4998
|
+
function findValue (source, predicate, thisArg, yieldIndex) {
|
4999
|
+
return new AnonymousObservable(function (observer) {
|
5000
|
+
var i = 0;
|
5001
|
+
return source.subscribe(function (x) {
|
5002
|
+
var shouldRun;
|
5003
|
+
try {
|
5004
|
+
shouldRun = predicate.call(thisArg, x, i, source);
|
5005
|
+
} catch (e) {
|
5006
|
+
observer.onError(e);
|
5007
|
+
return;
|
5008
|
+
}
|
5009
|
+
if (shouldRun) {
|
5010
|
+
observer.onNext(yieldIndex ? i : x);
|
5011
|
+
observer.onCompleted();
|
5012
|
+
} else {
|
5013
|
+
i++;
|
5014
|
+
}
|
5015
|
+
}, observer.onError.bind(observer), function () {
|
5016
|
+
observer.onNext(yieldIndex ? -1 : undefined);
|
5017
|
+
observer.onCompleted();
|
5018
|
+
});
|
5019
|
+
}, source);
|
5020
|
+
}
|
4859
5021
|
|
4860
|
-
|
4861
|
-
|
4862
|
-
|
4863
|
-
|
4864
|
-
|
4865
|
-
|
4866
|
-
|
4867
|
-
|
4868
|
-
|
5022
|
+
/**
|
5023
|
+
* Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire Observable sequence.
|
5024
|
+
* @param {Function} predicate The predicate that defines the conditions of the element to search for.
|
5025
|
+
* @param {Any} [thisArg] Object to use as `this` when executing the predicate.
|
5026
|
+
* @returns {Observable} An Observable sequence with the first element that matches the conditions defined by the specified predicate, if found; otherwise, undefined.
|
5027
|
+
*/
|
5028
|
+
observableProto.find = function (predicate, thisArg) {
|
5029
|
+
return findValue(this, predicate, thisArg, false);
|
5030
|
+
};
|
5031
|
+
|
5032
|
+
/**
|
5033
|
+
* Searches for an element that matches the conditions defined by the specified predicate, and returns
|
5034
|
+
* an Observable sequence with the zero-based index of the first occurrence within the entire Observable sequence.
|
5035
|
+
* @param {Function} predicate The predicate that defines the conditions of the element to search for.
|
5036
|
+
* @param {Any} [thisArg] Object to use as `this` when executing the predicate.
|
5037
|
+
* @returns {Observable} An Observable sequence with the zero-based index of the first occurrence of an element that matches the conditions defined by match, if found; otherwise, –1.
|
5038
|
+
*/
|
5039
|
+
observableProto.findIndex = function (predicate, thisArg) {
|
5040
|
+
return findValue(this, predicate, thisArg, true);
|
5041
|
+
};
|
5042
|
+
|
5043
|
+
|
5044
|
+
/**
|
5045
|
+
* Converts the observable sequence to a Set if it exists.
|
5046
|
+
* @returns {Observable} An observable sequence with a single value of a Set containing the values from the observable sequence.
|
5047
|
+
*/
|
5048
|
+
observableProto.toSet = function () {
|
5049
|
+
if (typeof root.Set === 'undefined') { throw new TypeError(); }
|
5050
|
+
var source = this;
|
5051
|
+
return new AnonymousObservable(function (observer) {
|
5052
|
+
var s = new root.Set();
|
5053
|
+
return source.subscribe(
|
5054
|
+
s.add.bind(s),
|
5055
|
+
observer.onError.bind(observer),
|
5056
|
+
function () {
|
5057
|
+
observer.onNext(s);
|
5058
|
+
observer.onCompleted();
|
5059
|
+
});
|
5060
|
+
}, source);
|
5061
|
+
};
|
4869
5062
|
|
4870
|
-
/**
|
4871
|
-
* Searches for an element that matches the conditions defined by the specified predicate, and returns
|
4872
|
-
* an Observable sequence with the zero-based index of the first occurrence within the entire Observable sequence.
|
4873
|
-
* @param {Function} predicate The predicate that defines the conditions of the element to search for.
|
4874
|
-
* @param {Any} [thisArg] Object to use as `this` when executing the predicate.
|
4875
|
-
* @returns {Observable} An Observable sequence with the zero-based index of the first occurrence of an element that matches the conditions defined by match, if found; otherwise, –1.
|
4876
|
-
*/
|
4877
|
-
observableProto.findIndex = function (predicate, thisArg) {
|
4878
|
-
return findValue(this, predicate, thisArg, true);
|
4879
|
-
};
|
4880
5063
|
|
4881
|
-
|
4882
|
-
|
4883
|
-
|
4884
|
-
|
4885
|
-
|
4886
|
-
|
4887
|
-
|
4888
|
-
|
4889
|
-
|
4890
|
-
|
4891
|
-
|
4892
|
-
|
4893
|
-
|
4894
|
-
|
4895
|
-
|
4896
|
-
|
4897
|
-
|
4898
|
-
|
4899
|
-
|
5064
|
+
/**
|
5065
|
+
* Converts the observable sequence to a Map if it exists.
|
5066
|
+
* @param {Function} keySelector A function which produces the key for the Map.
|
5067
|
+
* @param {Function} [elementSelector] An optional function which produces the element for the Map. If not present, defaults to the value from the observable sequence.
|
5068
|
+
* @returns {Observable} An observable sequence with a single value of a Map containing the values from the observable sequence.
|
5069
|
+
*/
|
5070
|
+
observableProto.toMap = function (keySelector, elementSelector) {
|
5071
|
+
if (typeof root.Map === 'undefined') { throw new TypeError(); }
|
5072
|
+
var source = this;
|
5073
|
+
return new AnonymousObservable(function (observer) {
|
5074
|
+
var m = new root.Map();
|
5075
|
+
return source.subscribe(
|
5076
|
+
function (x) {
|
5077
|
+
var key;
|
5078
|
+
try {
|
5079
|
+
key = keySelector(x);
|
5080
|
+
} catch (e) {
|
5081
|
+
observer.onError(e);
|
5082
|
+
return;
|
5083
|
+
}
|
4900
5084
|
|
4901
|
-
|
4902
|
-
|
4903
|
-
* Converts the observable sequence to a Map if it exists.
|
4904
|
-
* @param {Function} keySelector A function which produces the key for the Map.
|
4905
|
-
* @param {Function} [elementSelector] An optional function which produces the element for the Map. If not present, defaults to the value from the observable sequence.
|
4906
|
-
* @returns {Observable} An observable sequence with a single value of a Map containing the values from the observable sequence.
|
4907
|
-
*/
|
4908
|
-
observableProto.toMap = function (keySelector, elementSelector) {
|
4909
|
-
var source = this;
|
4910
|
-
return new AnonymousObservable(function (observer) {
|
4911
|
-
var m = new root.Map();
|
4912
|
-
return source.subscribe(
|
4913
|
-
function (x) {
|
4914
|
-
var key;
|
5085
|
+
var element = x;
|
5086
|
+
if (elementSelector) {
|
4915
5087
|
try {
|
4916
|
-
|
5088
|
+
element = elementSelector(x);
|
4917
5089
|
} catch (e) {
|
4918
5090
|
observer.onError(e);
|
4919
5091
|
return;
|
4920
5092
|
}
|
5093
|
+
}
|
4921
5094
|
|
4922
|
-
|
4923
|
-
|
4924
|
-
|
4925
|
-
|
4926
|
-
|
4927
|
-
|
4928
|
-
|
4929
|
-
|
4930
|
-
|
4931
|
-
|
4932
|
-
m.set(key, element);
|
4933
|
-
},
|
4934
|
-
observer.onError.bind(observer),
|
4935
|
-
function () {
|
4936
|
-
observer.onNext(m);
|
4937
|
-
observer.onCompleted();
|
4938
|
-
});
|
4939
|
-
});
|
4940
|
-
};
|
4941
|
-
}
|
5095
|
+
m.set(key, element);
|
5096
|
+
},
|
5097
|
+
observer.onError.bind(observer),
|
5098
|
+
function () {
|
5099
|
+
observer.onNext(m);
|
5100
|
+
observer.onCompleted();
|
5101
|
+
});
|
5102
|
+
}, source);
|
5103
|
+
};
|
4942
5104
|
|
4943
5105
|
var fnString = 'function',
|
4944
5106
|
throwString = 'throw';
|
@@ -4983,7 +5145,7 @@ if (!Array.prototype.forEach) {
|
|
4983
5145
|
return --pending || done(null, results);
|
4984
5146
|
}
|
4985
5147
|
|
4986
|
-
fn.call(ctx, function(err, res){
|
5148
|
+
fn.call(ctx, function(err, res) {
|
4987
5149
|
if (finished) { return; }
|
4988
5150
|
|
4989
5151
|
if (err) {
|
@@ -5018,7 +5180,7 @@ if (!Array.prototype.forEach) {
|
|
5018
5180
|
}
|
5019
5181
|
|
5020
5182
|
function promiseToThunk(promise) {
|
5021
|
-
return function(fn){
|
5183
|
+
return function(fn) {
|
5022
5184
|
promise.then(function(res) {
|
5023
5185
|
fn(null, res);
|
5024
5186
|
}, fn);
|
@@ -5074,7 +5236,9 @@ if (!Array.prototype.forEach) {
|
|
5074
5236
|
var ret;
|
5075
5237
|
|
5076
5238
|
// multiple args
|
5077
|
-
if (arguments.length > 2)
|
5239
|
+
if (arguments.length > 2) {
|
5240
|
+
res = slice.call(arguments, 1);
|
5241
|
+
}
|
5078
5242
|
|
5079
5243
|
if (err) {
|
5080
5244
|
try {
|
@@ -5101,7 +5265,7 @@ if (!Array.prototype.forEach) {
|
|
5101
5265
|
if (typeof ret.value === fnString) {
|
5102
5266
|
var called = false;
|
5103
5267
|
try {
|
5104
|
-
ret.value.call(ctx, function(){
|
5268
|
+
ret.value.call(ctx, function() {
|
5105
5269
|
if (called) {
|
5106
5270
|
return;
|
5107
5271
|
}
|
@@ -5134,13 +5298,13 @@ if (!Array.prototype.forEach) {
|
|
5134
5298
|
* @returns {Function} A function, when executed will continue the state machine.
|
5135
5299
|
*/
|
5136
5300
|
Rx.denodify = function (fn) {
|
5137
|
-
return function (){
|
5301
|
+
return function () {
|
5138
5302
|
var args = slice.call(arguments),
|
5139
5303
|
results,
|
5140
5304
|
called,
|
5141
5305
|
callback;
|
5142
5306
|
|
5143
|
-
args.push(function(){
|
5307
|
+
args.push(function() {
|
5144
5308
|
results = arguments;
|
5145
5309
|
|
5146
5310
|
if (callback && !called) {
|
@@ -5151,7 +5315,7 @@ if (!Array.prototype.forEach) {
|
|
5151
5315
|
|
5152
5316
|
fn.apply(this, args);
|
5153
5317
|
|
5154
|
-
return function (fn){
|
5318
|
+
return function (fn) {
|
5155
5319
|
callback = fn;
|
5156
5320
|
|
5157
5321
|
if (results && !called) {
|
@@ -5164,7 +5328,7 @@ if (!Array.prototype.forEach) {
|
|
5164
5328
|
|
5165
5329
|
function error(err) {
|
5166
5330
|
if (!err) { return; }
|
5167
|
-
timeoutScheduler.schedule(function(){
|
5331
|
+
timeoutScheduler.schedule(function() {
|
5168
5332
|
throw err;
|
5169
5333
|
});
|
5170
5334
|
}
|
@@ -5192,12 +5356,6 @@ if (!Array.prototype.forEach) {
|
|
5192
5356
|
|
5193
5357
|
/**
|
5194
5358
|
* Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
|
5195
|
-
*
|
5196
|
-
* @example
|
5197
|
-
* var res = Rx.Observable.toAsync(function (x, y) { return x + y; })(4, 3);
|
5198
|
-
* var res = Rx.Observable.toAsync(function (x, y) { return x + y; }, Rx.Scheduler.timeout)(4, 3);
|
5199
|
-
* var res = Rx.Observable.toAsync(function (x) { this.log(x); }, Rx.Scheduler.timeout, console)('hello');
|
5200
|
-
*
|
5201
5359
|
* @param {Function} function Function to convert to an asynchronous function.
|
5202
5360
|
* @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout.
|
5203
5361
|
* @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
|
@@ -5237,12 +5395,12 @@ if (!Array.prototype.forEach) {
|
|
5237
5395
|
var args = slice.call(arguments, 0);
|
5238
5396
|
|
5239
5397
|
return new AnonymousObservable(function (observer) {
|
5240
|
-
function handler(
|
5241
|
-
var results =
|
5398
|
+
function handler() {
|
5399
|
+
var results = arguments;
|
5242
5400
|
|
5243
5401
|
if (selector) {
|
5244
5402
|
try {
|
5245
|
-
results = selector(
|
5403
|
+
results = selector(results);
|
5246
5404
|
} catch (err) {
|
5247
5405
|
observer.onError(err);
|
5248
5406
|
return;
|
@@ -5339,12 +5497,12 @@ if (!Array.prototype.forEach) {
|
|
5339
5497
|
event.relatedTarget = event.toElement;
|
5340
5498
|
}
|
5341
5499
|
// Adding stopPropogation and preventDefault to IE
|
5342
|
-
if (!event.stopPropagation){
|
5500
|
+
if (!event.stopPropagation) {
|
5343
5501
|
event.stopPropagation = stopPropagation;
|
5344
5502
|
event.preventDefault = preventDefault;
|
5345
5503
|
}
|
5346
5504
|
// Normalize key events
|
5347
|
-
switch(event.type){
|
5505
|
+
switch (event.type) {
|
5348
5506
|
case 'keypress':
|
5349
5507
|
var c = ('charCode' in event ? event.charCode : event.keyCode);
|
5350
5508
|
if (c == 10) {
|
@@ -5591,17 +5749,22 @@ if (!Array.prototype.forEach) {
|
|
5591
5749
|
|
5592
5750
|
function combineLatestSource(source, subject, resultSelector) {
|
5593
5751
|
return new AnonymousObservable(function (observer) {
|
5594
|
-
var
|
5595
|
-
hasValue = [false, false],
|
5752
|
+
var hasValue = [false, false],
|
5596
5753
|
hasValueAll = false,
|
5597
5754
|
isDone = false,
|
5598
|
-
values = new Array(
|
5755
|
+
values = new Array(2),
|
5756
|
+
err;
|
5599
5757
|
|
5600
5758
|
function next(x, i) {
|
5601
5759
|
values[i] = x
|
5602
5760
|
var res;
|
5603
5761
|
hasValue[i] = true;
|
5604
5762
|
if (hasValueAll || (hasValueAll = hasValue.every(identity))) {
|
5763
|
+
if (err) {
|
5764
|
+
observer.onError(err);
|
5765
|
+
return;
|
5766
|
+
}
|
5767
|
+
|
5605
5768
|
try {
|
5606
5769
|
res = resultSelector.apply(null, values);
|
5607
5770
|
} catch (ex) {
|
@@ -5609,7 +5772,8 @@ if (!Array.prototype.forEach) {
|
|
5609
5772
|
return;
|
5610
5773
|
}
|
5611
5774
|
observer.onNext(res);
|
5612
|
-
}
|
5775
|
+
}
|
5776
|
+
if (isDone && values[1]) {
|
5613
5777
|
observer.onCompleted();
|
5614
5778
|
}
|
5615
5779
|
}
|
@@ -5619,23 +5783,33 @@ if (!Array.prototype.forEach) {
|
|
5619
5783
|
function (x) {
|
5620
5784
|
next(x, 0);
|
5621
5785
|
},
|
5622
|
-
|
5786
|
+
function (e) {
|
5787
|
+
if (values[1]) {
|
5788
|
+
observer.onError(e);
|
5789
|
+
} else {
|
5790
|
+
err = e;
|
5791
|
+
}
|
5792
|
+
},
|
5623
5793
|
function () {
|
5624
5794
|
isDone = true;
|
5625
|
-
observer.onCompleted();
|
5795
|
+
values[1] && observer.onCompleted();
|
5626
5796
|
}),
|
5627
5797
|
subject.subscribe(
|
5628
5798
|
function (x) {
|
5629
5799
|
next(x, 1);
|
5630
5800
|
},
|
5631
|
-
observer.onError.bind(observer)
|
5801
|
+
observer.onError.bind(observer),
|
5802
|
+
function () {
|
5803
|
+
isDone = true;
|
5804
|
+
next(true, 1);
|
5805
|
+
})
|
5632
5806
|
);
|
5633
5807
|
});
|
5634
5808
|
}
|
5635
5809
|
|
5636
|
-
var PausableBufferedObservable = (function (
|
5810
|
+
var PausableBufferedObservable = (function (__super__) {
|
5637
5811
|
|
5638
|
-
inherits(PausableBufferedObservable,
|
5812
|
+
inherits(PausableBufferedObservable, __super__);
|
5639
5813
|
|
5640
5814
|
function subscribe(observer) {
|
5641
5815
|
var q = [], previousShouldFire;
|
@@ -5695,7 +5869,7 @@ if (!Array.prototype.forEach) {
|
|
5695
5869
|
this.pauser = this.controller;
|
5696
5870
|
}
|
5697
5871
|
|
5698
|
-
|
5872
|
+
__super__.call(this, subscribe);
|
5699
5873
|
}
|
5700
5874
|
|
5701
5875
|
PausableBufferedObservable.prototype.pause = function () {
|
@@ -5909,7 +6083,7 @@ if (!Array.prototype.forEach) {
|
|
5909
6083
|
new AnonymousObservable(function (observer) {
|
5910
6084
|
var connectable = source.multicast(subjectOrSubjectSelector());
|
5911
6085
|
return new CompositeDisposable(selector(connectable).subscribe(observer), connectable.connect());
|
5912
|
-
}) :
|
6086
|
+
}, source) :
|
5913
6087
|
new ConnectableObservable(source, subjectOrSubjectSelector);
|
5914
6088
|
};
|
5915
6089
|
|
@@ -5933,10 +6107,6 @@ if (!Array.prototype.forEach) {
|
|
5933
6107
|
/**
|
5934
6108
|
* Returns an observable sequence that shares a single subscription to the underlying sequence.
|
5935
6109
|
* 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.
|
5936
|
-
*
|
5937
|
-
* @example
|
5938
|
-
* var res = source.share();
|
5939
|
-
*
|
5940
6110
|
* @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence.
|
5941
6111
|
*/
|
5942
6112
|
observableProto.share = function () {
|
@@ -5983,10 +6153,6 @@ if (!Array.prototype.forEach) {
|
|
5983
6153
|
/**
|
5984
6154
|
* Returns an observable sequence that shares a single subscription to the underlying sequence and starts with an initialValue.
|
5985
6155
|
* 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.
|
5986
|
-
*
|
5987
|
-
* @example
|
5988
|
-
* var res = source.shareValue(42);
|
5989
|
-
*
|
5990
6156
|
* @param {Mixed} initialValue Initial value received by observers upon subscription.
|
5991
6157
|
* @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence.
|
5992
6158
|
*/
|
@@ -6173,21 +6339,17 @@ if (!Array.prototype.forEach) {
|
|
6173
6339
|
this._trim(this.scheduler.now());
|
6174
6340
|
this.observers.push(so);
|
6175
6341
|
|
6176
|
-
var n = this.q.length;
|
6177
|
-
|
6178
6342
|
for (var i = 0, len = this.q.length; i < len; i++) {
|
6179
6343
|
so.onNext(this.q[i].value);
|
6180
6344
|
}
|
6181
6345
|
|
6182
6346
|
if (this.hasError) {
|
6183
|
-
n++;
|
6184
6347
|
so.onError(this.error);
|
6185
6348
|
} else if (this.isStopped) {
|
6186
|
-
n++;
|
6187
6349
|
so.onCompleted();
|
6188
6350
|
}
|
6189
6351
|
|
6190
|
-
so.ensureActive(
|
6352
|
+
so.ensureActive();
|
6191
6353
|
return subscription;
|
6192
6354
|
}
|
6193
6355
|
|
@@ -6339,7 +6501,7 @@ if (!Array.prototype.forEach) {
|
|
6339
6501
|
duplicatekey = "duplicate key";
|
6340
6502
|
|
6341
6503
|
function isPrime(candidate) {
|
6342
|
-
if (candidate & 1 === 0) { return candidate === 2; }
|
6504
|
+
if ((candidate & 1) === 0) { return candidate === 2; }
|
6343
6505
|
var num1 = Math.sqrt(candidate),
|
6344
6506
|
num2 = 3;
|
6345
6507
|
while (num2 <= num1) {
|
@@ -6368,7 +6530,7 @@ if (!Array.prototype.forEach) {
|
|
6368
6530
|
if (!str.length) { return hash; }
|
6369
6531
|
for (var i = 0, len = str.length; i < len; i++) {
|
6370
6532
|
var character = str.charCodeAt(i);
|
6371
|
-
hash = ((hash<<5)-hash)+character;
|
6533
|
+
hash = ((hash << 5) - hash) + character;
|
6372
6534
|
hash = hash & hash;
|
6373
6535
|
}
|
6374
6536
|
return hash;
|
@@ -6402,10 +6564,10 @@ if (!Array.prototype.forEach) {
|
|
6402
6564
|
if (typeof valueOf === 'number') { return numberHashFn(valueOf); }
|
6403
6565
|
if (typeof obj === 'string') { return stringHashFn(valueOf); }
|
6404
6566
|
}
|
6405
|
-
if (obj.
|
6567
|
+
if (obj.hashCode) { return obj.hashCode(); }
|
6406
6568
|
|
6407
6569
|
var id = 17 * uniqueIdCounter++;
|
6408
|
-
obj.
|
6570
|
+
obj.hashCode = function () { return id; };
|
6409
6571
|
return id;
|
6410
6572
|
};
|
6411
6573
|
}());
|
@@ -6438,7 +6600,7 @@ if (!Array.prototype.forEach) {
|
|
6438
6600
|
};
|
6439
6601
|
|
6440
6602
|
dictionaryProto.add = function (key, value) {
|
6441
|
-
|
6603
|
+
this._insert(key, value, true);
|
6442
6604
|
};
|
6443
6605
|
|
6444
6606
|
dictionaryProto._insert = function (key, value, add) {
|
@@ -6666,7 +6828,7 @@ if (!Array.prototype.forEach) {
|
|
6666
6828
|
var result;
|
6667
6829
|
try {
|
6668
6830
|
result = resultSelector(v, value);
|
6669
|
-
} catch(exn) {
|
6831
|
+
} catch (exn) {
|
6670
6832
|
observer.onError(exn);
|
6671
6833
|
return;
|
6672
6834
|
}
|
@@ -6681,7 +6843,7 @@ if (!Array.prototype.forEach) {
|
|
6681
6843
|
})
|
6682
6844
|
);
|
6683
6845
|
return group;
|
6684
|
-
});
|
6846
|
+
}, left);
|
6685
6847
|
};
|
6686
6848
|
|
6687
6849
|
/**
|
@@ -6793,7 +6955,7 @@ if (!Array.prototype.forEach) {
|
|
6793
6955
|
);
|
6794
6956
|
|
6795
6957
|
return r;
|
6796
|
-
});
|
6958
|
+
}, left);
|
6797
6959
|
};
|
6798
6960
|
|
6799
6961
|
/**
|
@@ -6863,7 +7025,7 @@ if (!Array.prototype.forEach) {
|
|
6863
7025
|
}));
|
6864
7026
|
|
6865
7027
|
return r;
|
6866
|
-
});
|
7028
|
+
}, source);
|
6867
7029
|
}
|
6868
7030
|
|
6869
7031
|
function observableWindowWithClosingSelector(windowClosingSelector) {
|
@@ -6883,7 +7045,7 @@ if (!Array.prototype.forEach) {
|
|
6883
7045
|
win.onCompleted();
|
6884
7046
|
observer.onCompleted();
|
6885
7047
|
}));
|
6886
|
-
|
7048
|
+
|
6887
7049
|
function createWindowClose () {
|
6888
7050
|
var windowClose;
|
6889
7051
|
try {
|
@@ -6910,7 +7072,7 @@ if (!Array.prototype.forEach) {
|
|
6910
7072
|
|
6911
7073
|
createWindowClose();
|
6912
7074
|
return r;
|
6913
|
-
});
|
7075
|
+
}, source);
|
6914
7076
|
}
|
6915
7077
|
|
6916
7078
|
/**
|
@@ -6934,7 +7096,7 @@ if (!Array.prototype.forEach) {
|
|
6934
7096
|
},
|
6935
7097
|
observer.onError.bind(observer),
|
6936
7098
|
observer.onCompleted.bind(observer));
|
6937
|
-
});
|
7099
|
+
}, source);
|
6938
7100
|
};
|
6939
7101
|
|
6940
7102
|
/**
|
@@ -6968,16 +7130,16 @@ if (!Array.prototype.forEach) {
|
|
6968
7130
|
});
|
6969
7131
|
}
|
6970
7132
|
|
6971
|
-
|
6972
|
-
|
6973
|
-
|
6974
|
-
|
6975
|
-
|
6976
|
-
|
6977
|
-
|
6978
|
-
|
6979
|
-
|
6980
|
-
|
7133
|
+
/**
|
7134
|
+
* Returns an observable sequence that is the result of invoking the selector on the source sequence, without sharing subscriptions.
|
7135
|
+
* This operator allows for a fluent style of writing queries that use the same sequence multiple times.
|
7136
|
+
*
|
7137
|
+
* @param {Function} selector Selector function which can use the source sequence as many times as needed, without sharing subscriptions to the source sequence.
|
7138
|
+
* @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
|
7139
|
+
*/
|
7140
|
+
observableProto.letBind = observableProto['let'] = function (func) {
|
7141
|
+
return func(this);
|
7142
|
+
};
|
6981
7143
|
|
6982
7144
|
/**
|
6983
7145
|
* Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers <IE9
|
@@ -7028,16 +7190,16 @@ if (!Array.prototype.forEach) {
|
|
7028
7190
|
return enumerableWhile(condition, source).concat();
|
7029
7191
|
};
|
7030
7192
|
|
7031
|
-
|
7032
|
-
|
7033
|
-
|
7034
|
-
|
7035
|
-
|
7036
|
-
|
7037
|
-
|
7038
|
-
|
7039
|
-
|
7040
|
-
|
7193
|
+
/**
|
7194
|
+
* Repeats source as long as condition holds emulating a do while loop.
|
7195
|
+
*
|
7196
|
+
* @param {Function} condition The condition which determines if the source will be repeated.
|
7197
|
+
* @param {Observable} source The observable sequence that will be run if the condition function returns true.
|
7198
|
+
* @returns {Observable} An observable sequence which is repeated as long as the condition holds.
|
7199
|
+
*/
|
7200
|
+
observableProto.doWhile = function (condition) {
|
7201
|
+
return observableConcat([this, observableWhileDo(condition, this)]);
|
7202
|
+
};
|
7041
7203
|
|
7042
7204
|
/**
|
7043
7205
|
* Uses selector to determine which source in sources to use.
|
@@ -7088,8 +7250,8 @@ if (!Array.prototype.forEach) {
|
|
7088
7250
|
var ensureActive = function () {
|
7089
7251
|
var isOwner = false;
|
7090
7252
|
if (q.length > 0) {
|
7091
|
-
|
7092
|
-
|
7253
|
+
isOwner = !isAcquired;
|
7254
|
+
isAcquired = true;
|
7093
7255
|
}
|
7094
7256
|
if (isOwner) {
|
7095
7257
|
m.setDisposable(scheduler.scheduleRecursive(function (self) {
|
@@ -7129,7 +7291,7 @@ if (!Array.prototype.forEach) {
|
|
7129
7291
|
activeCount++;
|
7130
7292
|
ensureActive();
|
7131
7293
|
return d;
|
7132
|
-
});
|
7294
|
+
}, this);
|
7133
7295
|
};
|
7134
7296
|
|
7135
7297
|
/**
|
@@ -7270,7 +7432,7 @@ if (!Array.prototype.forEach) {
|
|
7270
7432
|
);
|
7271
7433
|
|
7272
7434
|
return new CompositeDisposable(leftSubscription, rightSubscription);
|
7273
|
-
});
|
7435
|
+
}, first);
|
7274
7436
|
};
|
7275
7437
|
|
7276
7438
|
/**
|
@@ -7301,7 +7463,7 @@ if (!Array.prototype.forEach) {
|
|
7301
7463
|
)
|
7302
7464
|
.observeOn(scheduler)
|
7303
7465
|
.map(selector);
|
7304
|
-
});
|
7466
|
+
}, source);
|
7305
7467
|
};
|
7306
7468
|
|
7307
7469
|
var ChainObservable = (function (__super__) {
|
@@ -7310,7 +7472,7 @@ if (!Array.prototype.forEach) {
|
|
7310
7472
|
var self = this, g = new CompositeDisposable();
|
7311
7473
|
g.add(currentThreadScheduler.schedule(function () {
|
7312
7474
|
observer.onNext(self.head);
|
7313
|
-
g.add(self.tail.
|
7475
|
+
g.add(self.tail.mergeAll().subscribe(observer));
|
7314
7476
|
}));
|
7315
7477
|
|
7316
7478
|
return g;
|
@@ -7746,7 +7908,7 @@ if (!Array.prototype.forEach) {
|
|
7746
7908
|
}
|
7747
7909
|
});
|
7748
7910
|
return new CompositeDisposable(subscription, cancelable);
|
7749
|
-
});
|
7911
|
+
}, source);
|
7750
7912
|
}
|
7751
7913
|
|
7752
7914
|
function observableDelayDate(source, dueTime, scheduler) {
|
@@ -7778,16 +7940,11 @@ if (!Array.prototype.forEach) {
|
|
7778
7940
|
|
7779
7941
|
/**
|
7780
7942
|
* Ignores values from an observable sequence which are followed by another value before dueTime.
|
7781
|
-
*
|
7782
|
-
* @
|
7783
|
-
*
|
7784
|
-
* 2 - res = source.throttle(5000, scheduler);
|
7785
|
-
*
|
7786
|
-
* @param {Number} dueTime Duration of the throttle period for each value (specified as an integer denoting milliseconds).
|
7787
|
-
* @param {Scheduler} [scheduler] Scheduler to run the throttle timers on. If not specified, the timeout scheduler is used.
|
7788
|
-
* @returns {Observable} The throttled sequence.
|
7943
|
+
* @param {Number} dueTime Duration of the debounce period for each value (specified as an integer denoting milliseconds).
|
7944
|
+
* @param {Scheduler} [scheduler] Scheduler to run the debounce timers on. If not specified, the timeout scheduler is used.
|
7945
|
+
* @returns {Observable} The debounced sequence.
|
7789
7946
|
*/
|
7790
|
-
observableProto.
|
7947
|
+
observableProto.debounce = observableProto.throttleWithTimeout = function (dueTime, scheduler) {
|
7791
7948
|
isScheduler(scheduler) || (scheduler = timeoutScheduler);
|
7792
7949
|
var source = this;
|
7793
7950
|
return new AnonymousObservable(function (observer) {
|
@@ -7819,7 +7976,15 @@ if (!Array.prototype.forEach) {
|
|
7819
7976
|
id++;
|
7820
7977
|
});
|
7821
7978
|
return new CompositeDisposable(subscription, cancelable);
|
7822
|
-
});
|
7979
|
+
}, this);
|
7980
|
+
};
|
7981
|
+
|
7982
|
+
/**
|
7983
|
+
* @deprecated use #debounce or #throttleWithTimeout instead.
|
7984
|
+
*/
|
7985
|
+
observableProto.throttle = function(dueTime, scheduler) {
|
7986
|
+
deprecate('throttle', 'debounce or throttleWithTimeout');
|
7987
|
+
return this.debounce(dueTime, scheduler);
|
7823
7988
|
};
|
7824
7989
|
|
7825
7990
|
/**
|
@@ -7888,18 +8053,18 @@ if (!Array.prototype.forEach) {
|
|
7888
8053
|
groupDisposable.add(source.subscribe(
|
7889
8054
|
function (x) {
|
7890
8055
|
for (var i = 0, len = q.length; i < len; i++) { q[i].onNext(x); }
|
7891
|
-
},
|
8056
|
+
},
|
7892
8057
|
function (e) {
|
7893
8058
|
for (var i = 0, len = q.length; i < len; i++) { q[i].onError(e); }
|
7894
8059
|
observer.onError(e);
|
7895
|
-
},
|
8060
|
+
},
|
7896
8061
|
function () {
|
7897
8062
|
for (var i = 0, len = q.length; i < len; i++) { q[i].onCompleted(); }
|
7898
8063
|
observer.onCompleted();
|
7899
8064
|
}
|
7900
8065
|
));
|
7901
8066
|
return refCountDisposable;
|
7902
|
-
});
|
8067
|
+
}, source);
|
7903
8068
|
};
|
7904
8069
|
|
7905
8070
|
/**
|
@@ -7933,7 +8098,7 @@ if (!Array.prototype.forEach) {
|
|
7933
8098
|
createTimer(newId);
|
7934
8099
|
}));
|
7935
8100
|
}
|
7936
|
-
|
8101
|
+
|
7937
8102
|
observer.onNext(addRef(s, refCountDisposable));
|
7938
8103
|
createTimer(0);
|
7939
8104
|
|
@@ -7950,7 +8115,7 @@ if (!Array.prototype.forEach) {
|
|
7950
8115
|
observer.onNext(addRef(s, refCountDisposable));
|
7951
8116
|
}
|
7952
8117
|
newWindow && createTimer(newId);
|
7953
|
-
},
|
8118
|
+
},
|
7954
8119
|
function (e) {
|
7955
8120
|
s.onError(e);
|
7956
8121
|
observer.onError(e);
|
@@ -7960,7 +8125,7 @@ if (!Array.prototype.forEach) {
|
|
7960
8125
|
}
|
7961
8126
|
));
|
7962
8127
|
return refCountDisposable;
|
7963
|
-
});
|
8128
|
+
}, source);
|
7964
8129
|
};
|
7965
8130
|
|
7966
8131
|
/**
|
@@ -8038,7 +8203,6 @@ if (!Array.prototype.forEach) {
|
|
8038
8203
|
};
|
8039
8204
|
|
8040
8205
|
function sampleObservable(source, sampler) {
|
8041
|
-
|
8042
8206
|
return new AnonymousObservable(function (observer) {
|
8043
8207
|
var atEnd, value, hasValue;
|
8044
8208
|
|
@@ -8059,7 +8223,7 @@ if (!Array.prototype.forEach) {
|
|
8059
8223
|
}),
|
8060
8224
|
sampler.subscribe(sampleSubscribe, observer.onError.bind(observer), sampleSubscribe)
|
8061
8225
|
);
|
8062
|
-
});
|
8226
|
+
}, source);
|
8063
8227
|
}
|
8064
8228
|
|
8065
8229
|
/**
|
@@ -8074,7 +8238,7 @@ if (!Array.prototype.forEach) {
|
|
8074
8238
|
* @param {Scheduler} [scheduler] Scheduler to run the sampling timer on. If not specified, the timeout scheduler is used.
|
8075
8239
|
* @returns {Observable} Sampled observable sequence.
|
8076
8240
|
*/
|
8077
|
-
observableProto.sample = function (intervalOrSampler, scheduler) {
|
8241
|
+
observableProto.sample = observableProto.throttleLatest = function (intervalOrSampler, scheduler) {
|
8078
8242
|
isScheduler(scheduler) || (scheduler = timeoutScheduler);
|
8079
8243
|
return typeof intervalOrSampler === 'number' ?
|
8080
8244
|
sampleObservable(this, observableinterval(intervalOrSampler, scheduler)) :
|
@@ -8135,7 +8299,7 @@ if (!Array.prototype.forEach) {
|
|
8135
8299
|
}
|
8136
8300
|
}));
|
8137
8301
|
return new CompositeDisposable(subscription, timer);
|
8138
|
-
});
|
8302
|
+
}, source);
|
8139
8303
|
};
|
8140
8304
|
|
8141
8305
|
/**
|
@@ -8261,68 +8425,64 @@ if (!Array.prototype.forEach) {
|
|
8261
8425
|
return this.delayWithSelector(observableTimer(dueTime, isScheduler(scheduler) ? scheduler : timeoutScheduler), observableEmpty);
|
8262
8426
|
};
|
8263
8427
|
|
8264
|
-
|
8265
|
-
|
8266
|
-
|
8267
|
-
|
8268
|
-
|
8269
|
-
|
8270
|
-
|
8271
|
-
|
8272
|
-
|
8273
|
-
|
8274
|
-
|
8275
|
-
|
8276
|
-
|
8277
|
-
|
8278
|
-
|
8279
|
-
|
8280
|
-
|
8281
|
-
|
8282
|
-
|
8283
|
-
|
8284
|
-
|
8285
|
-
|
8286
|
-
|
8287
|
-
|
8288
|
-
|
8289
|
-
|
8290
|
-
|
8291
|
-
|
8292
|
-
|
8293
|
-
|
8294
|
-
|
8295
|
-
|
8296
|
-
|
8297
|
-
|
8298
|
-
|
8299
|
-
|
8300
|
-
|
8301
|
-
|
8302
|
-
|
8303
|
-
|
8304
|
-
|
8305
|
-
|
8306
|
-
|
8307
|
-
|
8308
|
-
|
8309
|
-
|
8310
|
-
|
8311
|
-
|
8312
|
-
}));
|
8313
|
-
};
|
8428
|
+
/**
|
8429
|
+
* Time shifts the observable sequence based on a subscription delay and a delay selector function for each element.
|
8430
|
+
*
|
8431
|
+
* @example
|
8432
|
+
* 1 - res = source.delayWithSelector(function (x) { return Rx.Scheduler.timer(5000); }); // with selector only
|
8433
|
+
* 1 - res = source.delayWithSelector(Rx.Observable.timer(2000), function (x) { return Rx.Observable.timer(x); }); // with delay and selector
|
8434
|
+
*
|
8435
|
+
* @param {Observable} [subscriptionDelay] Sequence indicating the delay for the subscription to the source.
|
8436
|
+
* @param {Function} delayDurationSelector Selector function to retrieve a sequence indicating the delay for each given element.
|
8437
|
+
* @returns {Observable} Time-shifted sequence.
|
8438
|
+
*/
|
8439
|
+
observableProto.delayWithSelector = function (subscriptionDelay, delayDurationSelector) {
|
8440
|
+
var source = this, subDelay, selector;
|
8441
|
+
if (typeof subscriptionDelay === 'function') {
|
8442
|
+
selector = subscriptionDelay;
|
8443
|
+
} else {
|
8444
|
+
subDelay = subscriptionDelay;
|
8445
|
+
selector = delayDurationSelector;
|
8446
|
+
}
|
8447
|
+
return new AnonymousObservable(function (observer) {
|
8448
|
+
var delays = new CompositeDisposable(), atEnd = false, done = function () {
|
8449
|
+
if (atEnd && delays.length === 0) { observer.onCompleted(); }
|
8450
|
+
}, subscription = new SerialDisposable(), start = function () {
|
8451
|
+
subscription.setDisposable(source.subscribe(function (x) {
|
8452
|
+
var delay;
|
8453
|
+
try {
|
8454
|
+
delay = selector(x);
|
8455
|
+
} catch (error) {
|
8456
|
+
observer.onError(error);
|
8457
|
+
return;
|
8458
|
+
}
|
8459
|
+
var d = new SingleAssignmentDisposable();
|
8460
|
+
delays.add(d);
|
8461
|
+
d.setDisposable(delay.subscribe(function () {
|
8462
|
+
observer.onNext(x);
|
8463
|
+
delays.remove(d);
|
8464
|
+
done();
|
8465
|
+
}, observer.onError.bind(observer), function () {
|
8466
|
+
observer.onNext(x);
|
8467
|
+
delays.remove(d);
|
8468
|
+
done();
|
8469
|
+
}));
|
8470
|
+
}, observer.onError.bind(observer), function () {
|
8471
|
+
atEnd = true;
|
8472
|
+
subscription.dispose();
|
8473
|
+
done();
|
8474
|
+
}));
|
8475
|
+
};
|
8314
8476
|
|
8315
|
-
|
8316
|
-
|
8317
|
-
|
8318
|
-
|
8319
|
-
|
8320
|
-
}, observer.onError.bind(observer), function () { start(); }));
|
8321
|
-
}
|
8477
|
+
if (!subDelay) {
|
8478
|
+
start();
|
8479
|
+
} else {
|
8480
|
+
subscription.setDisposable(subDelay.subscribe(start, observer.onError.bind(observer), start));
|
8481
|
+
}
|
8322
8482
|
|
8323
|
-
|
8324
|
-
|
8325
|
-
|
8483
|
+
return new CompositeDisposable(subscription, delays);
|
8484
|
+
}, this);
|
8485
|
+
};
|
8326
8486
|
|
8327
8487
|
/**
|
8328
8488
|
* Returns the source observable sequence, switching to the other observable sequence if a timeout is signaled.
|
@@ -8390,26 +8550,22 @@ if (!Array.prototype.forEach) {
|
|
8390
8550
|
observerWins() && observer.onCompleted();
|
8391
8551
|
}));
|
8392
8552
|
return new CompositeDisposable(subscription, timer);
|
8393
|
-
});
|
8553
|
+
}, source);
|
8394
8554
|
};
|
8395
8555
|
|
8396
8556
|
/**
|
8397
|
-
*
|
8398
|
-
*
|
8399
|
-
* @
|
8400
|
-
* 1 - res = source.delayWithSelector(function (x) { return Rx.Scheduler.timer(x + x); });
|
8401
|
-
*
|
8402
|
-
* @param {Function} throttleDurationSelector Selector function to retrieve a sequence indicating the throttle duration for each given element.
|
8403
|
-
* @returns {Observable} The throttled sequence.
|
8557
|
+
* Ignores values from an observable sequence which are followed by another value within a computed throttle duration.
|
8558
|
+
* @param {Function} durationSelector Selector function to retrieve a sequence indicating the throttle duration for each given element.
|
8559
|
+
* @returns {Observable} The debounced sequence.
|
8404
8560
|
*/
|
8405
|
-
observableProto.
|
8561
|
+
observableProto.debounceWithSelector = function (durationSelector) {
|
8406
8562
|
var source = this;
|
8407
8563
|
return new AnonymousObservable(function (observer) {
|
8408
8564
|
var value, hasValue = false, cancelable = new SerialDisposable(), id = 0;
|
8409
8565
|
var subscription = source.subscribe(function (x) {
|
8410
8566
|
var throttle;
|
8411
8567
|
try {
|
8412
|
-
throttle =
|
8568
|
+
throttle = durationSelector(x);
|
8413
8569
|
} catch (e) {
|
8414
8570
|
observer.onError(e);
|
8415
8571
|
return;
|
@@ -8444,7 +8600,12 @@ if (!Array.prototype.forEach) {
|
|
8444
8600
|
id++;
|
8445
8601
|
});
|
8446
8602
|
return new CompositeDisposable(subscription, cancelable);
|
8447
|
-
});
|
8603
|
+
}, source);
|
8604
|
+
};
|
8605
|
+
|
8606
|
+
observableProto.throttleWithSelector = function () {
|
8607
|
+
deprecate('throttleWithSelector', 'debounceWithSelector');
|
8608
|
+
return this.debounceWithSelector.apply(this, arguments);
|
8448
8609
|
};
|
8449
8610
|
|
8450
8611
|
/**
|
@@ -8479,7 +8640,7 @@ if (!Array.prototype.forEach) {
|
|
8479
8640
|
}
|
8480
8641
|
observer.onCompleted();
|
8481
8642
|
});
|
8482
|
-
});
|
8643
|
+
}, source);
|
8483
8644
|
};
|
8484
8645
|
|
8485
8646
|
/**
|
@@ -8511,7 +8672,7 @@ if (!Array.prototype.forEach) {
|
|
8511
8672
|
}
|
8512
8673
|
observer.onCompleted();
|
8513
8674
|
});
|
8514
|
-
});
|
8675
|
+
}, source);
|
8515
8676
|
};
|
8516
8677
|
|
8517
8678
|
/**
|
@@ -8544,7 +8705,7 @@ if (!Array.prototype.forEach) {
|
|
8544
8705
|
observer.onNext(res);
|
8545
8706
|
observer.onCompleted();
|
8546
8707
|
});
|
8547
|
-
});
|
8708
|
+
}, source);
|
8548
8709
|
};
|
8549
8710
|
|
8550
8711
|
/**
|
@@ -8565,7 +8726,7 @@ if (!Array.prototype.forEach) {
|
|
8565
8726
|
isScheduler(scheduler) || (scheduler = timeoutScheduler);
|
8566
8727
|
return new AnonymousObservable(function (observer) {
|
8567
8728
|
return new CompositeDisposable(scheduler.scheduleWithRelative(duration, observer.onCompleted.bind(observer)), source.subscribe(observer));
|
8568
|
-
});
|
8729
|
+
}, source);
|
8569
8730
|
};
|
8570
8731
|
|
8571
8732
|
/**
|
@@ -8592,7 +8753,7 @@ if (!Array.prototype.forEach) {
|
|
8592
8753
|
return new CompositeDisposable(
|
8593
8754
|
scheduler.scheduleWithRelative(duration, function () { open = true; }),
|
8594
8755
|
source.subscribe(function (x) { open && observer.onNext(x); }, observer.onError.bind(observer), observer.onCompleted.bind(observer)));
|
8595
|
-
});
|
8756
|
+
}, source);
|
8596
8757
|
};
|
8597
8758
|
|
8598
8759
|
/**
|
@@ -8620,7 +8781,7 @@ if (!Array.prototype.forEach) {
|
|
8620
8781
|
function (x) { open && observer.onNext(x); },
|
8621
8782
|
observer.onError.bind(observer),
|
8622
8783
|
observer.onCompleted.bind(observer)));
|
8623
|
-
});
|
8784
|
+
}, source);
|
8624
8785
|
};
|
8625
8786
|
|
8626
8787
|
/**
|
@@ -8638,7 +8799,34 @@ if (!Array.prototype.forEach) {
|
|
8638
8799
|
return new CompositeDisposable(
|
8639
8800
|
scheduler[schedulerMethod](endTime, observer.onCompleted.bind(observer)),
|
8640
8801
|
source.subscribe(observer));
|
8641
|
-
});
|
8802
|
+
}, source);
|
8803
|
+
};
|
8804
|
+
|
8805
|
+
/**
|
8806
|
+
* Returns an Observable that emits only the first item emitted by the source Observable during sequential time windows of a specified duration.
|
8807
|
+
* @param {Number} windowDuration time to wait before emitting another item after emitting the last item
|
8808
|
+
* @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.
|
8809
|
+
* @returns {Observable} An Observable that performs the throttle operation.
|
8810
|
+
*/
|
8811
|
+
observableProto.throttleFirst = function (windowDuration, scheduler) {
|
8812
|
+
isScheduler(scheduler) || (scheduler = timeoutScheduler);
|
8813
|
+
var duration = +windowDuration || 0;
|
8814
|
+
if (duration <= 0) { throw new RangeError('windowDuration cannot be less or equal zero.'); }
|
8815
|
+
var source = this;
|
8816
|
+
return new AnonymousObservable(function (observer) {
|
8817
|
+
var lastOnNext = 0;
|
8818
|
+
return source.subscribe(
|
8819
|
+
function (x) {
|
8820
|
+
var now = scheduler.now();
|
8821
|
+
if (lastOnNext === 0 || now - lastOnNext >= duration) {
|
8822
|
+
lastOnNext = now;
|
8823
|
+
observer.onNext(x);
|
8824
|
+
}
|
8825
|
+
},
|
8826
|
+
observer.onError.bind(observer),
|
8827
|
+
observer.onCompleted.bind(observer)
|
8828
|
+
);
|
8829
|
+
}, source);
|
8642
8830
|
};
|
8643
8831
|
|
8644
8832
|
/*
|
@@ -8687,7 +8875,7 @@ if (!Array.prototype.forEach) {
|
|
8687
8875
|
}));
|
8688
8876
|
|
8689
8877
|
return g;
|
8690
|
-
});
|
8878
|
+
}, this);
|
8691
8879
|
};
|
8692
8880
|
|
8693
8881
|
/*
|
@@ -8750,11 +8938,11 @@ if (!Array.prototype.forEach) {
|
|
8750
8938
|
}
|
8751
8939
|
}));
|
8752
8940
|
return g;
|
8753
|
-
});
|
8941
|
+
}, this);
|
8754
8942
|
};
|
8755
8943
|
|
8756
8944
|
/**
|
8757
|
-
* Executes a transducer to transform the observable sequence
|
8945
|
+
* Executes a transducer to transform the observable sequence
|
8758
8946
|
* @param {Transducer} transducer A transducer to execute
|
8759
8947
|
* @returns {Observable} An Observable sequence containing the results from the transducer.
|
8760
8948
|
*/
|
@@ -8778,17 +8966,17 @@ if (!Array.prototype.forEach) {
|
|
8778
8966
|
return new AnonymousObservable(function(observer) {
|
8779
8967
|
var xform = transducer(transformForObserver(observer));
|
8780
8968
|
return source.subscribe(
|
8781
|
-
function(v) {
|
8969
|
+
function(v) {
|
8782
8970
|
try {
|
8783
8971
|
xform.step(observer, v);
|
8784
8972
|
} catch (e) {
|
8785
8973
|
observer.onError(e);
|
8786
8974
|
}
|
8787
|
-
},
|
8788
|
-
observer.onError.bind(observer),
|
8975
|
+
},
|
8976
|
+
observer.onError.bind(observer),
|
8789
8977
|
function() { xform.result(observer); }
|
8790
8978
|
);
|
8791
|
-
});
|
8979
|
+
}, source);
|
8792
8980
|
};
|
8793
8981
|
|
8794
8982
|
/** Provides a set of extension methods for virtual time scheduling. */
|
@@ -9078,7 +9266,8 @@ if (!Array.prototype.forEach) {
|
|
9078
9266
|
disposableEmpty;
|
9079
9267
|
}
|
9080
9268
|
|
9081
|
-
function AnonymousObservable(subscribe) {
|
9269
|
+
function AnonymousObservable(subscribe, parent) {
|
9270
|
+
this.source = parent;
|
9082
9271
|
if (!(this instanceof AnonymousObservable)) {
|
9083
9272
|
return new AnonymousObservable(subscribe);
|
9084
9273
|
}
|
@@ -9111,66 +9300,59 @@ if (!Array.prototype.forEach) {
|
|
9111
9300
|
|
9112
9301
|
}(Observable));
|
9113
9302
|
|
9114
|
-
|
9115
|
-
|
9116
|
-
inherits(AutoDetachObserver, _super);
|
9303
|
+
var AutoDetachObserver = (function (__super__) {
|
9304
|
+
inherits(AutoDetachObserver, __super__);
|
9117
9305
|
|
9118
|
-
|
9119
|
-
|
9120
|
-
|
9121
|
-
|
9122
|
-
|
9306
|
+
function AutoDetachObserver(observer) {
|
9307
|
+
__super__.call(this);
|
9308
|
+
this.observer = observer;
|
9309
|
+
this.m = new SingleAssignmentDisposable();
|
9310
|
+
}
|
9123
9311
|
|
9124
|
-
|
9312
|
+
var AutoDetachObserverPrototype = AutoDetachObserver.prototype;
|
9125
9313
|
|
9126
|
-
|
9127
|
-
|
9128
|
-
|
9129
|
-
|
9130
|
-
|
9131
|
-
|
9132
|
-
|
9133
|
-
|
9134
|
-
|
9135
|
-
|
9136
|
-
|
9137
|
-
}
|
9138
|
-
};
|
9314
|
+
AutoDetachObserverPrototype.next = function (value) {
|
9315
|
+
var noError = false;
|
9316
|
+
try {
|
9317
|
+
this.observer.onNext(value);
|
9318
|
+
noError = true;
|
9319
|
+
} catch (e) {
|
9320
|
+
throw e;
|
9321
|
+
} finally {
|
9322
|
+
!noError && this.dispose();
|
9323
|
+
}
|
9324
|
+
};
|
9139
9325
|
|
9140
|
-
|
9141
|
-
|
9142
|
-
|
9143
|
-
|
9144
|
-
|
9145
|
-
|
9146
|
-
|
9147
|
-
|
9148
|
-
|
9326
|
+
AutoDetachObserverPrototype.error = function (err) {
|
9327
|
+
try {
|
9328
|
+
this.observer.onError(err);
|
9329
|
+
} catch (e) {
|
9330
|
+
throw e;
|
9331
|
+
} finally {
|
9332
|
+
this.dispose();
|
9333
|
+
}
|
9334
|
+
};
|
9149
9335
|
|
9150
|
-
|
9151
|
-
|
9152
|
-
|
9153
|
-
|
9154
|
-
|
9155
|
-
|
9156
|
-
|
9157
|
-
|
9158
|
-
|
9336
|
+
AutoDetachObserverPrototype.completed = function () {
|
9337
|
+
try {
|
9338
|
+
this.observer.onCompleted();
|
9339
|
+
} catch (e) {
|
9340
|
+
throw e;
|
9341
|
+
} finally {
|
9342
|
+
this.dispose();
|
9343
|
+
}
|
9344
|
+
};
|
9159
9345
|
|
9160
|
-
|
9161
|
-
|
9162
|
-
/* @private */
|
9163
|
-
AutoDetachObserverPrototype.disposable = function (value) {
|
9164
|
-
return arguments.length ? this.getDisposable() : setDisposable(value);
|
9165
|
-
};
|
9346
|
+
AutoDetachObserverPrototype.setDisposable = function (value) { this.m.setDisposable(value); };
|
9347
|
+
AutoDetachObserverPrototype.getDisposable = function () { return this.m.getDisposable(); };
|
9166
9348
|
|
9167
|
-
|
9168
|
-
|
9169
|
-
|
9170
|
-
|
9349
|
+
AutoDetachObserverPrototype.dispose = function () {
|
9350
|
+
__super__.prototype.dispose.call(this);
|
9351
|
+
this.m.dispose();
|
9352
|
+
};
|
9171
9353
|
|
9172
|
-
|
9173
|
-
|
9354
|
+
return AutoDetachObserver;
|
9355
|
+
}(AbstractObserver));
|
9174
9356
|
|
9175
9357
|
var GroupedObservable = (function (__super__) {
|
9176
9358
|
inherits(GroupedObservable, __super__);
|
@@ -9466,4 +9648,7 @@ if (!Array.prototype.forEach) {
|
|
9466
9648
|
root.Rx = Rx;
|
9467
9649
|
}
|
9468
9650
|
|
9651
|
+
// All code before this point will be filtered from stack traces.
|
9652
|
+
var rEndingLine = captureLine();
|
9653
|
+
|
9469
9654
|
}.call(this));
|