rxjs-rails 2.2.27 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +0 -3
- data/lib/rxjs/rails/version.rb +1 -1
- data/vendor/assets/javascripts/rx.aggregates.min.js +1 -1
- data/vendor/assets/javascripts/rx.all.compat.js +1545 -1441
- data/vendor/assets/javascripts/rx.all.compat.min.js +3 -3
- data/vendor/assets/javascripts/rx.all.js +1545 -1441
- data/vendor/assets/javascripts/rx.all.min.js +3 -3
- data/vendor/assets/javascripts/rx.async.compat.js +149 -152
- data/vendor/assets/javascripts/rx.async.compat.min.js +1 -1
- data/vendor/assets/javascripts/rx.async.js +140 -143
- data/vendor/assets/javascripts/rx.async.min.js +1 -1
- data/vendor/assets/javascripts/rx.backpressure.min.js +1 -1
- data/vendor/assets/javascripts/rx.binding.js +18 -18
- data/vendor/assets/javascripts/rx.binding.min.js +1 -1
- data/vendor/assets/javascripts/rx.coincidence.min.js +1 -1
- data/vendor/assets/javascripts/rx.compat.js +490 -339
- data/vendor/assets/javascripts/rx.compat.min.js +2 -2
- data/vendor/assets/javascripts/rx.core.compat.js +109 -141
- data/vendor/assets/javascripts/rx.core.compat.min.js +1 -1
- data/vendor/assets/javascripts/rx.core.js +109 -141
- data/vendor/assets/javascripts/rx.core.min.js +1 -1
- data/vendor/assets/javascripts/rx.experimental.js +129 -136
- data/vendor/assets/javascripts/rx.experimental.min.js +1 -1
- data/vendor/assets/javascripts/rx.joinpatterns.js +59 -59
- data/vendor/assets/javascripts/rx.joinpatterns.min.js +1 -1
- data/vendor/assets/javascripts/rx.js +490 -339
- data/vendor/assets/javascripts/rx.lite.compat.js +1099 -954
- data/vendor/assets/javascripts/rx.lite.compat.min.js +2 -2
- data/vendor/assets/javascripts/rx.lite.extras.min.js +1 -1
- data/vendor/assets/javascripts/rx.lite.js +1099 -954
- data/vendor/assets/javascripts/rx.lite.min.js +2 -2
- data/vendor/assets/javascripts/rx.min.js +2 -2
- data/vendor/assets/javascripts/rx.testing.min.js +1 -1
- data/vendor/assets/javascripts/rx.time.js +715 -747
- data/vendor/assets/javascripts/rx.time.min.js +1 -1
- data/vendor/assets/javascripts/rx.virtualtime.min.js +1 -1
- metadata +11 -10
@@ -31,6 +31,8 @@
|
|
31
31
|
|
32
32
|
// Defaults
|
33
33
|
var noop = Rx.helpers.noop = function () { },
|
34
|
+
notDefined = Rx.helpers.notDefined = function (x) { return typeof x === 'undefined'; },
|
35
|
+
isScheduler = Rx.helpers.isScheduler = function (x) { return x instanceof Rx.Scheduler; },
|
34
36
|
identity = Rx.helpers.identity = function (x) { return x; },
|
35
37
|
pluck = Rx.helpers.pluck = function (property) { return function (x) { return x[property]; }; },
|
36
38
|
just = Rx.helpers.just = function (value) { return function () { return value; }; },
|
@@ -50,14 +52,13 @@
|
|
50
52
|
function checkDisposed() { if (this.isDisposed) { throw new Error(objectDisposed); } }
|
51
53
|
|
52
54
|
// Shim in iterator support
|
53
|
-
var $iterator$ = (typeof Symbol === '
|
55
|
+
var $iterator$ = (typeof Symbol === 'function' && Symbol.iterator) ||
|
54
56
|
'_es6shim_iterator_';
|
55
|
-
//
|
56
|
-
// https://bugzilla.mozilla.org/show_bug.cgi?id=907077#c14
|
57
|
-
// So use that name if we detect it.
|
57
|
+
// Bug for mozilla version
|
58
58
|
if (root.Set && typeof new root.Set()['@@iterator'] === 'function') {
|
59
59
|
$iterator$ = '@@iterator';
|
60
60
|
}
|
61
|
+
|
61
62
|
var doneEnumerator = { done: true, value: undefined };
|
62
63
|
|
63
64
|
/** `Object#toString` result shortcuts */
|
@@ -1394,140 +1395,111 @@
|
|
1394
1395
|
return CatchScheduler;
|
1395
1396
|
}(Scheduler));
|
1396
1397
|
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
var NotificationPrototype = Notification.prototype;
|
1407
|
-
|
1408
|
-
/**
|
1409
|
-
* Invokes the delegate corresponding to the notification or the observer's method corresponding to the notification and returns the produced result.
|
1410
|
-
*
|
1411
|
-
* @memberOf Notification
|
1412
|
-
* @param {Any} observerOrOnNext Delegate to invoke for an OnNext notification or Observer to invoke the notification on..
|
1413
|
-
* @param {Function} onError Delegate to invoke for an OnError notification.
|
1414
|
-
* @param {Function} onCompleted Delegate to invoke for an OnCompleted notification.
|
1415
|
-
* @returns {Any} Result produced by the observation.
|
1416
|
-
*/
|
1417
|
-
NotificationPrototype.accept = function (observerOrOnNext, onError, onCompleted) {
|
1418
|
-
if (arguments.length === 1 && typeof observerOrOnNext === 'object') {
|
1419
|
-
return this._acceptObservable(observerOrOnNext);
|
1420
|
-
}
|
1421
|
-
return this._accept(observerOrOnNext, onError, onCompleted);
|
1422
|
-
};
|
1423
|
-
|
1424
|
-
/**
|
1425
|
-
* Returns an observable sequence with a single notification.
|
1426
|
-
*
|
1427
|
-
* @memberOf Notification
|
1428
|
-
* @param {Scheduler} [scheduler] Scheduler to send out the notification calls on.
|
1429
|
-
* @returns {Observable} The observable sequence that surfaces the behavior of the notification upon subscription.
|
1430
|
-
*/
|
1431
|
-
NotificationPrototype.toObservable = function (scheduler) {
|
1432
|
-
var notification = this;
|
1433
|
-
scheduler || (scheduler = immediateScheduler);
|
1434
|
-
return new AnonymousObservable(function (observer) {
|
1435
|
-
return scheduler.schedule(function () {
|
1436
|
-
notification._acceptObservable(observer);
|
1437
|
-
if (notification.kind === 'N') {
|
1438
|
-
observer.onCompleted();
|
1439
|
-
}
|
1440
|
-
});
|
1441
|
-
});
|
1442
|
-
};
|
1443
|
-
|
1444
|
-
return Notification;
|
1445
|
-
})();
|
1398
|
+
/**
|
1399
|
+
* Represents a notification to an observer.
|
1400
|
+
*/
|
1401
|
+
var Notification = Rx.Notification = (function () {
|
1402
|
+
function Notification(kind, hasValue) {
|
1403
|
+
this.hasValue = hasValue == null ? false : hasValue;
|
1404
|
+
this.kind = kind;
|
1405
|
+
}
|
1446
1406
|
|
1447
1407
|
/**
|
1448
|
-
*
|
1449
|
-
*
|
1450
|
-
* @
|
1408
|
+
* Invokes the delegate corresponding to the notification or the observer's method corresponding to the notification and returns the produced result.
|
1409
|
+
*
|
1410
|
+
* @memberOf Notification
|
1411
|
+
* @param {Any} observerOrOnNext Delegate to invoke for an OnNext notification or Observer to invoke the notification on..
|
1412
|
+
* @param {Function} onError Delegate to invoke for an OnError notification.
|
1413
|
+
* @param {Function} onCompleted Delegate to invoke for an OnCompleted notification.
|
1414
|
+
* @returns {Any} Result produced by the observation.
|
1451
1415
|
*/
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
function _acceptObservable(observer) {
|
1459
|
-
return observer.onNext(this.value);
|
1460
|
-
}
|
1461
|
-
|
1462
|
-
function toString () {
|
1463
|
-
return 'OnNext(' + this.value + ')';
|
1464
|
-
}
|
1465
|
-
|
1466
|
-
return function (value) {
|
1467
|
-
var notification = new Notification('N', true);
|
1468
|
-
notification.value = value;
|
1469
|
-
notification._accept = _accept;
|
1470
|
-
notification._acceptObservable = _acceptObservable;
|
1471
|
-
notification.toString = toString;
|
1472
|
-
return notification;
|
1473
|
-
};
|
1474
|
-
}());
|
1416
|
+
Notification.prototype.accept = function (observerOrOnNext, onError, onCompleted) {
|
1417
|
+
return observerOrOnNext && typeof observerOrOnNext === 'object' ?
|
1418
|
+
this._acceptObservable(observerOrOnNext) :
|
1419
|
+
this._accept(observerOrOnNext, onError, onCompleted);
|
1420
|
+
};
|
1475
1421
|
|
1476
1422
|
/**
|
1477
|
-
*
|
1478
|
-
*
|
1479
|
-
* @
|
1423
|
+
* Returns an observable sequence with a single notification.
|
1424
|
+
*
|
1425
|
+
* @memberOf Notifications
|
1426
|
+
* @param {Scheduler} [scheduler] Scheduler to send out the notification calls on.
|
1427
|
+
* @returns {Observable} The observable sequence that surfaces the behavior of the notification upon subscription.
|
1480
1428
|
*/
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1491
|
-
function toString () {
|
1492
|
-
return 'OnError(' + this.exception + ')';
|
1493
|
-
}
|
1429
|
+
Notification.prototype.toObservable = function (scheduler) {
|
1430
|
+
var notification = this;
|
1431
|
+
isScheduler(scheduler) || (scheduler = immediateScheduler);
|
1432
|
+
return new AnonymousObservable(function (observer) {
|
1433
|
+
return scheduler.schedule(function () {
|
1434
|
+
notification._acceptObservable(observer);
|
1435
|
+
notification.kind === 'N' && observer.onCompleted();
|
1436
|
+
});
|
1437
|
+
});
|
1438
|
+
};
|
1494
1439
|
|
1495
|
-
|
1496
|
-
|
1497
|
-
notification.exception = exception;
|
1498
|
-
notification._accept = _accept;
|
1499
|
-
notification._acceptObservable = _acceptObservable;
|
1500
|
-
notification.toString = toString;
|
1501
|
-
return notification;
|
1502
|
-
};
|
1503
|
-
}());
|
1440
|
+
return Notification;
|
1441
|
+
})();
|
1504
1442
|
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1443
|
+
/**
|
1444
|
+
* Creates an object that represents an OnNext notification to an observer.
|
1445
|
+
* @param {Any} value The value contained in the notification.
|
1446
|
+
* @returns {Notification} The OnNext notification containing the value.
|
1447
|
+
*/
|
1448
|
+
var notificationCreateOnNext = Notification.createOnNext = (function () {
|
1449
|
+
|
1450
|
+
function _accept (onNext) { return onNext(this.value); }
|
1451
|
+
function _acceptObservable(observer) { return observer.onNext(this.value); }
|
1452
|
+
function toString () { return 'OnNext(' + this.value + ')'; }
|
1453
|
+
|
1454
|
+
return function (value) {
|
1455
|
+
var notification = new Notification('N', true);
|
1456
|
+
notification.value = value;
|
1457
|
+
notification._accept = _accept;
|
1458
|
+
notification._acceptObservable = _acceptObservable;
|
1459
|
+
notification.toString = toString;
|
1460
|
+
return notification;
|
1461
|
+
};
|
1462
|
+
}());
|
1510
1463
|
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1464
|
+
/**
|
1465
|
+
* Creates an object that represents an OnError notification to an observer.
|
1466
|
+
* @param {Any} error The exception contained in the notification.
|
1467
|
+
* @returns {Notification} The OnError notification containing the exception.
|
1468
|
+
*/
|
1469
|
+
var notificationCreateOnError = Notification.createOnError = (function () {
|
1470
|
+
|
1471
|
+
function _accept (onNext, onError) { return onError(this.exception); }
|
1472
|
+
function _acceptObservable(observer) { return observer.onError(this.exception); }
|
1473
|
+
function toString () { return 'OnError(' + this.exception + ')'; }
|
1474
|
+
|
1475
|
+
return function (exception) {
|
1476
|
+
var notification = new Notification('E');
|
1477
|
+
notification.exception = exception;
|
1478
|
+
notification._accept = _accept;
|
1479
|
+
notification._acceptObservable = _acceptObservable;
|
1480
|
+
notification.toString = toString;
|
1481
|
+
return notification;
|
1482
|
+
};
|
1483
|
+
}());
|
1514
1484
|
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1485
|
+
/**
|
1486
|
+
* Creates an object that represents an OnCompleted notification to an observer.
|
1487
|
+
* @returns {Notification} The OnCompleted notification.
|
1488
|
+
*/
|
1489
|
+
var notificationCreateOnCompleted = Notification.createOnCompleted = (function () {
|
1518
1490
|
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1491
|
+
function _accept (onNext, onError, onCompleted) { return onCompleted(); }
|
1492
|
+
function _acceptObservable(observer) { return observer.onCompleted(); }
|
1493
|
+
function toString () { return 'OnCompleted()'; }
|
1522
1494
|
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
|
1495
|
+
return function () {
|
1496
|
+
var notification = new Notification('C');
|
1497
|
+
notification._accept = _accept;
|
1498
|
+
notification._acceptObservable = _acceptObservable;
|
1499
|
+
notification.toString = toString;
|
1500
|
+
return notification;
|
1501
|
+
};
|
1502
|
+
}());
|
1531
1503
|
|
1532
1504
|
var Enumerator = Rx.internals.Enumerator = function (next) {
|
1533
1505
|
this._next = next;
|
@@ -2207,130 +2179,180 @@
|
|
2207
2179
|
});
|
2208
2180
|
};
|
2209
2181
|
|
2210
|
-
|
2211
|
-
|
2212
|
-
|
2213
|
-
|
2214
|
-
|
2215
|
-
|
2216
|
-
|
2217
|
-
|
2218
|
-
|
2219
|
-
|
2220
|
-
|
2221
|
-
|
2222
|
-
|
2223
|
-
|
2224
|
-
|
2225
|
-
|
2226
|
-
|
2182
|
+
/**
|
2183
|
+
* Returns an empty observable sequence, using the specified scheduler to send out the single OnCompleted message.
|
2184
|
+
*
|
2185
|
+
* @example
|
2186
|
+
* var res = Rx.Observable.empty();
|
2187
|
+
* var res = Rx.Observable.empty(Rx.Scheduler.timeout);
|
2188
|
+
* @param {Scheduler} [scheduler] Scheduler to send the termination call on.
|
2189
|
+
* @returns {Observable} An observable sequence with no elements.
|
2190
|
+
*/
|
2191
|
+
var observableEmpty = Observable.empty = function (scheduler) {
|
2192
|
+
isScheduler(scheduler) || (scheduler = immediateScheduler);
|
2193
|
+
return new AnonymousObservable(function (observer) {
|
2194
|
+
return scheduler.schedule(function () {
|
2195
|
+
observer.onCompleted();
|
2196
|
+
});
|
2197
|
+
});
|
2198
|
+
};
|
2227
2199
|
|
2228
|
-
|
2229
|
-
|
2230
|
-
|
2231
|
-
|
2232
|
-
|
2233
|
-
|
2234
|
-
|
2235
|
-
|
2236
|
-
|
2237
|
-
|
2238
|
-
|
2239
|
-
|
2240
|
-
|
2241
|
-
|
2242
|
-
|
2243
|
-
|
2244
|
-
|
2245
|
-
|
2246
|
-
|
2247
|
-
|
2248
|
-
|
2249
|
-
|
2250
|
-
|
2200
|
+
var maxSafeInteger = Math.pow(2, 53) - 1;
|
2201
|
+
|
2202
|
+
function numberIsFinite(value) {
|
2203
|
+
return typeof value === 'number' && root.isFinite(value);
|
2204
|
+
}
|
2205
|
+
|
2206
|
+
function isNan(n) {
|
2207
|
+
return n !== n;
|
2208
|
+
}
|
2209
|
+
|
2210
|
+
function isIterable(o) {
|
2211
|
+
return o[$iterator$] !== undefined;
|
2212
|
+
}
|
2213
|
+
|
2214
|
+
function sign(value) {
|
2215
|
+
var number = +value;
|
2216
|
+
if (number === 0) { return number; }
|
2217
|
+
if (isNaN(number)) { return number; }
|
2218
|
+
return number < 0 ? -1 : 1;
|
2219
|
+
}
|
2220
|
+
|
2221
|
+
function toLength(o) {
|
2222
|
+
var len = +o.length;
|
2223
|
+
if (isNaN(len)) { return 0; }
|
2224
|
+
if (len === 0 || !numberIsFinite(len)) { return len; }
|
2225
|
+
len = sign(len) * Math.floor(Math.abs(len));
|
2226
|
+
if (len <= 0) { return 0; }
|
2227
|
+
if (len > maxSafeInteger) { return maxSafeInteger; }
|
2228
|
+
return len;
|
2229
|
+
}
|
2230
|
+
|
2231
|
+
function isCallable(f) {
|
2232
|
+
return Object.prototype.toString.call(f) === '[object Function]' && typeof f === 'function';
|
2233
|
+
}
|
2251
2234
|
|
2252
2235
|
/**
|
2253
|
-
*
|
2236
|
+
* This method creates a new Observable sequence from an array-like or iterable object.
|
2237
|
+
* @param {Any} arrayLike An array-like or iterable object to convert to an Observable sequence.
|
2238
|
+
* @param {Function} [mapFn] Map function to call on every element of the array.
|
2239
|
+
* @param {Any} [thisArg] The context to use calling the mapFn if provided.
|
2240
|
+
* @param {Scheduler} [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread.
|
2241
|
+
*/
|
2242
|
+
Observable.from = function (iterable, mapFn, thisArg, scheduler) {
|
2243
|
+
if (iterable == null) {
|
2244
|
+
throw new Error('iterable cannot be null.')
|
2245
|
+
}
|
2246
|
+
if (mapFn && !isCallable(mapFn)) {
|
2247
|
+
throw new Error('mapFn when provided must be a function');
|
2248
|
+
}
|
2249
|
+
isScheduler(scheduler) || (scheduler = currentThreadScheduler);
|
2250
|
+
return new AnonymousObservable(function (observer) {
|
2251
|
+
var list = Object(iterable),
|
2252
|
+
objIsIterable = isIterable(list),
|
2253
|
+
len = objIsIterable ? 0 : toLength(list),
|
2254
|
+
it = objIsIterable ? list[$iterator$]() : null,
|
2255
|
+
i = 0;
|
2256
|
+
return scheduler.scheduleRecursive(function (self) {
|
2257
|
+
if (i < len || objIsIterable) {
|
2258
|
+
var result;
|
2259
|
+
if (objIsIterable) {
|
2260
|
+
var next = it.next();
|
2261
|
+
if (next.done) {
|
2262
|
+
observer.onCompleted();
|
2263
|
+
return;
|
2264
|
+
}
|
2265
|
+
|
2266
|
+
result = next.value;
|
2267
|
+
} else {
|
2268
|
+
result = list[i];
|
2269
|
+
}
|
2270
|
+
|
2271
|
+
if (mapFn && isCallable(mapFn)) {
|
2272
|
+
try {
|
2273
|
+
result = thisArg ? mapFn.call(thisArg, result, i) : mapFn(result, i);
|
2274
|
+
} catch (e) {
|
2275
|
+
observer.onError(e);
|
2276
|
+
return;
|
2277
|
+
}
|
2278
|
+
}
|
2279
|
+
|
2280
|
+
observer.onNext(result);
|
2281
|
+
i++;
|
2282
|
+
self();
|
2283
|
+
} else {
|
2284
|
+
observer.onCompleted();
|
2285
|
+
}
|
2286
|
+
});
|
2287
|
+
});
|
2288
|
+
};
|
2289
|
+
/**
|
2290
|
+
* Converts an array to an observable sequence, using an optional scheduler to enumerate the array.
|
2254
2291
|
*
|
2255
2292
|
* @example
|
2256
|
-
* var res = Rx.Observable.
|
2257
|
-
* var res = Rx.Observable.
|
2293
|
+
* var res = Rx.Observable.fromArray([1,2,3]);
|
2294
|
+
* var res = Rx.Observable.fromArray([1,2,3], Rx.Scheduler.timeout);
|
2258
2295
|
* @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on.
|
2259
|
-
* @returns {Observable} The observable sequence whose elements are pulled from the given
|
2296
|
+
* @returns {Observable} The observable sequence whose elements are pulled from the given enumerable sequence.
|
2260
2297
|
*/
|
2261
|
-
Observable.
|
2262
|
-
scheduler || (scheduler = currentThreadScheduler);
|
2298
|
+
var observableFromArray = Observable.fromArray = function (array, scheduler) {
|
2299
|
+
isScheduler(scheduler) || (scheduler = currentThreadScheduler);
|
2263
2300
|
return new AnonymousObservable(function (observer) {
|
2264
|
-
var
|
2265
|
-
|
2266
|
-
|
2267
|
-
|
2268
|
-
|
2269
|
-
|
2270
|
-
|
2301
|
+
var count = 0, len = array.length;
|
2302
|
+
return scheduler.scheduleRecursive(function (self) {
|
2303
|
+
if (count < len) {
|
2304
|
+
observer.onNext(array[count++]);
|
2305
|
+
self();
|
2306
|
+
} else {
|
2307
|
+
observer.onCompleted();
|
2308
|
+
}
|
2309
|
+
});
|
2310
|
+
});
|
2311
|
+
};
|
2271
2312
|
|
2313
|
+
/**
|
2314
|
+
* Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler to send out observer messages.
|
2315
|
+
*
|
2316
|
+
* @example
|
2317
|
+
* var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; });
|
2318
|
+
* var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; }, Rx.Scheduler.timeout);
|
2319
|
+
* @param {Mixed} initialState Initial state.
|
2320
|
+
* @param {Function} condition Condition to terminate generation (upon returning false).
|
2321
|
+
* @param {Function} iterate Iteration step function.
|
2322
|
+
* @param {Function} resultSelector Selector function for results produced in the sequence.
|
2323
|
+
* @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not provided, defaults to Scheduler.currentThread.
|
2324
|
+
* @returns {Observable} The generated sequence.
|
2325
|
+
*/
|
2326
|
+
Observable.generate = function (initialState, condition, iterate, resultSelector, scheduler) {
|
2327
|
+
isScheduler(scheduler) || (scheduler = currentThreadScheduler);
|
2328
|
+
return new AnonymousObservable(function (observer) {
|
2329
|
+
var first = true, state = initialState;
|
2272
2330
|
return scheduler.scheduleRecursive(function (self) {
|
2273
|
-
var
|
2331
|
+
var hasResult, result;
|
2274
2332
|
try {
|
2275
|
-
|
2276
|
-
|
2277
|
-
|
2333
|
+
if (first) {
|
2334
|
+
first = false;
|
2335
|
+
} else {
|
2336
|
+
state = iterate(state);
|
2337
|
+
}
|
2338
|
+
hasResult = condition(state);
|
2339
|
+
if (hasResult) {
|
2340
|
+
result = resultSelector(state);
|
2341
|
+
}
|
2342
|
+
} catch (exception) {
|
2343
|
+
observer.onError(exception);
|
2278
2344
|
return;
|
2279
2345
|
}
|
2280
|
-
|
2281
|
-
|
2282
|
-
observer.onCompleted();
|
2283
|
-
} else {
|
2284
|
-
observer.onNext(next.value);
|
2346
|
+
if (hasResult) {
|
2347
|
+
observer.onNext(result);
|
2285
2348
|
self();
|
2349
|
+
} else {
|
2350
|
+
observer.onCompleted();
|
2286
2351
|
}
|
2287
2352
|
});
|
2288
2353
|
});
|
2289
2354
|
};
|
2290
2355
|
|
2291
|
-
/**
|
2292
|
-
* Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler to send out observer messages.
|
2293
|
-
*
|
2294
|
-
* @example
|
2295
|
-
* var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; });
|
2296
|
-
* var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; }, Rx.Scheduler.timeout);
|
2297
|
-
* @param {Mixed} initialState Initial state.
|
2298
|
-
* @param {Function} condition Condition to terminate generation (upon returning false).
|
2299
|
-
* @param {Function} iterate Iteration step function.
|
2300
|
-
* @param {Function} resultSelector Selector function for results produced in the sequence.
|
2301
|
-
* @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not provided, defaults to Scheduler.currentThread.
|
2302
|
-
* @returns {Observable} The generated sequence.
|
2303
|
-
*/
|
2304
|
-
Observable.generate = function (initialState, condition, iterate, resultSelector, scheduler) {
|
2305
|
-
scheduler || (scheduler = currentThreadScheduler);
|
2306
|
-
return new AnonymousObservable(function (observer) {
|
2307
|
-
var first = true, state = initialState;
|
2308
|
-
return scheduler.scheduleRecursive(function (self) {
|
2309
|
-
var hasResult, result;
|
2310
|
-
try {
|
2311
|
-
if (first) {
|
2312
|
-
first = false;
|
2313
|
-
} else {
|
2314
|
-
state = iterate(state);
|
2315
|
-
}
|
2316
|
-
hasResult = condition(state);
|
2317
|
-
if (hasResult) {
|
2318
|
-
result = resultSelector(state);
|
2319
|
-
}
|
2320
|
-
} catch (exception) {
|
2321
|
-
observer.onError(exception);
|
2322
|
-
return;
|
2323
|
-
}
|
2324
|
-
if (hasResult) {
|
2325
|
-
observer.onNext(result);
|
2326
|
-
self();
|
2327
|
-
} else {
|
2328
|
-
observer.onCompleted();
|
2329
|
-
}
|
2330
|
-
});
|
2331
|
-
});
|
2332
|
-
};
|
2333
|
-
|
2334
2356
|
/**
|
2335
2357
|
* Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins).
|
2336
2358
|
* @returns {Observable} An observable sequence whose observers will never get called.
|
@@ -2341,92 +2363,114 @@
|
|
2341
2363
|
});
|
2342
2364
|
};
|
2343
2365
|
|
2344
|
-
|
2345
|
-
|
2346
|
-
|
2347
|
-
|
2348
|
-
|
2349
|
-
|
2350
|
-
|
2351
|
-
|
2352
|
-
|
2353
|
-
|
2354
|
-
|
2355
|
-
Observable.range = function (start, count, scheduler) {
|
2356
|
-
scheduler || (scheduler = currentThreadScheduler);
|
2357
|
-
return new AnonymousObservable(function (observer) {
|
2358
|
-
return scheduler.scheduleRecursiveWithState(0, function (i, self) {
|
2359
|
-
if (i < count) {
|
2360
|
-
observer.onNext(start + i);
|
2361
|
-
self(i + 1);
|
2362
|
-
} else {
|
2363
|
-
observer.onCompleted();
|
2364
|
-
}
|
2365
|
-
});
|
2366
|
-
});
|
2367
|
-
};
|
2366
|
+
/**
|
2367
|
+
* This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.
|
2368
|
+
* @example
|
2369
|
+
* var res = Rx.Observable.of(1,2,3);
|
2370
|
+
* @returns {Observable} The observable sequence whose elements are pulled from the given arguments.
|
2371
|
+
*/
|
2372
|
+
Observable.of = function () {
|
2373
|
+
var len = arguments.length, args = new Array(len);
|
2374
|
+
for(var i = 0; i < len; i++) { args[i] = arguments[i]; }
|
2375
|
+
return observableFromArray(args);
|
2376
|
+
};
|
2368
2377
|
|
2369
|
-
|
2370
|
-
|
2371
|
-
|
2372
|
-
|
2373
|
-
|
2374
|
-
|
2375
|
-
|
2376
|
-
|
2377
|
-
|
2378
|
-
|
2379
|
-
|
2380
|
-
|
2381
|
-
|
2382
|
-
|
2383
|
-
|
2384
|
-
|
2385
|
-
|
2378
|
+
/**
|
2379
|
+
* This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.
|
2380
|
+
* @example
|
2381
|
+
* var res = Rx.Observable.of(1,2,3);
|
2382
|
+
* @param {Scheduler} scheduler A scheduler to use for scheduling the arguments.
|
2383
|
+
* @returns {Observable} The observable sequence whose elements are pulled from the given arguments.
|
2384
|
+
*/
|
2385
|
+
var observableOf = Observable.ofWithScheduler = function (scheduler) {
|
2386
|
+
var len = arguments.length - 1, args = new Array(len);
|
2387
|
+
for(var i = 0; i < len; i++) { args[i] = arguments[i + 1]; }
|
2388
|
+
return observableFromArray(args, scheduler);
|
2389
|
+
};
|
2390
|
+
|
2391
|
+
/**
|
2392
|
+
* Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to send out observer messages.
|
2393
|
+
*
|
2394
|
+
* @example
|
2395
|
+
* var res = Rx.Observable.range(0, 10);
|
2396
|
+
* var res = Rx.Observable.range(0, 10, Rx.Scheduler.timeout);
|
2397
|
+
* @param {Number} start The value of the first integer in the sequence.
|
2398
|
+
* @param {Number} count The number of sequential integers to generate.
|
2399
|
+
* @param {Scheduler} [scheduler] Scheduler to run the generator loop on. If not specified, defaults to Scheduler.currentThread.
|
2400
|
+
* @returns {Observable} An observable sequence that contains a range of sequential integral numbers.
|
2401
|
+
*/
|
2402
|
+
Observable.range = function (start, count, scheduler) {
|
2403
|
+
isScheduler(scheduler) || (scheduler = currentThreadScheduler);
|
2404
|
+
return new AnonymousObservable(function (observer) {
|
2405
|
+
return scheduler.scheduleRecursiveWithState(0, function (i, self) {
|
2406
|
+
if (i < count) {
|
2407
|
+
observer.onNext(start + i);
|
2408
|
+
self(i + 1);
|
2409
|
+
} else {
|
2410
|
+
observer.onCompleted();
|
2386
2411
|
}
|
2387
|
-
|
2388
|
-
};
|
2412
|
+
});
|
2413
|
+
});
|
2414
|
+
};
|
2389
2415
|
|
2390
|
-
|
2391
|
-
|
2392
|
-
|
2393
|
-
|
2394
|
-
|
2395
|
-
|
2396
|
-
|
2397
|
-
|
2398
|
-
|
2399
|
-
|
2400
|
-
|
2401
|
-
|
2402
|
-
|
2403
|
-
|
2404
|
-
|
2405
|
-
|
2406
|
-
|
2407
|
-
});
|
2408
|
-
});
|
2409
|
-
};
|
2416
|
+
/**
|
2417
|
+
* Generates an observable sequence that repeats the given element the specified number of times, using the specified scheduler to send out observer messages.
|
2418
|
+
*
|
2419
|
+
* @example
|
2420
|
+
* var res = Rx.Observable.repeat(42);
|
2421
|
+
* var res = Rx.Observable.repeat(42, 4);
|
2422
|
+
* 3 - res = Rx.Observable.repeat(42, 4, Rx.Scheduler.timeout);
|
2423
|
+
* 4 - res = Rx.Observable.repeat(42, null, Rx.Scheduler.timeout);
|
2424
|
+
* @param {Mixed} value Element to repeat.
|
2425
|
+
* @param {Number} repeatCount [Optiona] Number of times to repeat the element. If not specified, repeats indefinitely.
|
2426
|
+
* @param {Scheduler} scheduler Scheduler to run the producer loop on. If not specified, defaults to Scheduler.immediate.
|
2427
|
+
* @returns {Observable} An observable sequence that repeats the given element the specified number of times.
|
2428
|
+
*/
|
2429
|
+
Observable.repeat = function (value, repeatCount, scheduler) {
|
2430
|
+
isScheduler(scheduler) || (scheduler = currentThreadScheduler);
|
2431
|
+
return observableReturn(value, scheduler).repeat(repeatCount == null ? -1 : repeatCount);
|
2432
|
+
};
|
2410
2433
|
|
2411
|
-
|
2412
|
-
|
2413
|
-
|
2414
|
-
|
2415
|
-
|
2416
|
-
|
2417
|
-
|
2418
|
-
|
2419
|
-
|
2420
|
-
|
2421
|
-
|
2422
|
-
|
2423
|
-
|
2424
|
-
|
2425
|
-
|
2426
|
-
|
2427
|
-
|
2428
|
-
|
2429
|
-
};
|
2434
|
+
/**
|
2435
|
+
* Returns an observable sequence that contains a single element, using the specified scheduler to send out observer messages.
|
2436
|
+
* There is an alias called 'just', and 'returnValue' for browsers <IE9.
|
2437
|
+
*
|
2438
|
+
* @example
|
2439
|
+
* var res = Rx.Observable.return(42);
|
2440
|
+
* var res = Rx.Observable.return(42, Rx.Scheduler.timeout);
|
2441
|
+
* @param {Mixed} value Single element in the resulting observable sequence.
|
2442
|
+
* @param {Scheduler} scheduler Scheduler to send the single element on. If not specified, defaults to Scheduler.immediate.
|
2443
|
+
* @returns {Observable} An observable sequence containing the single specified element.
|
2444
|
+
*/
|
2445
|
+
var observableReturn = Observable['return'] = Observable.returnValue = Observable.just = function (value, scheduler) {
|
2446
|
+
isScheduler(scheduler) || (scheduler = immediateScheduler);
|
2447
|
+
return new AnonymousObservable(function (observer) {
|
2448
|
+
return scheduler.schedule(function () {
|
2449
|
+
observer.onNext(value);
|
2450
|
+
observer.onCompleted();
|
2451
|
+
});
|
2452
|
+
});
|
2453
|
+
};
|
2454
|
+
|
2455
|
+
/**
|
2456
|
+
* Returns an observable sequence that terminates with an exception, using the specified scheduler to send out the single onError message.
|
2457
|
+
* There is an alias to this method called 'throwException' for browsers <IE9.
|
2458
|
+
*
|
2459
|
+
* @example
|
2460
|
+
* var res = Rx.Observable.throw(new Error('Error'));
|
2461
|
+
* var res = Rx.Observable.throw(new Error('Error'), Rx.Scheduler.timeout);
|
2462
|
+
* @param {Mixed} exception An object used for the sequence's termination.
|
2463
|
+
* @param {Scheduler} scheduler Scheduler to send the exceptional termination call on. If not specified, defaults to Scheduler.immediate.
|
2464
|
+
* @returns {Observable} The observable sequence that terminates exceptionally with the specified exception object.
|
2465
|
+
*/
|
2466
|
+
var observableThrow = Observable['throw'] = Observable.throwException = function (exception, scheduler) {
|
2467
|
+
isScheduler(scheduler) || (scheduler = immediateScheduler);
|
2468
|
+
return new AnonymousObservable(function (observer) {
|
2469
|
+
return scheduler.schedule(function () {
|
2470
|
+
observer.onError(exception);
|
2471
|
+
});
|
2472
|
+
});
|
2473
|
+
};
|
2430
2474
|
|
2431
2475
|
/**
|
2432
2476
|
* Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence's lifetime.
|
@@ -3331,18 +3375,19 @@
|
|
3331
3375
|
return enumerableRepeat(this, repeatCount).concat();
|
3332
3376
|
};
|
3333
3377
|
|
3334
|
-
|
3335
|
-
|
3336
|
-
|
3337
|
-
|
3338
|
-
|
3339
|
-
|
3340
|
-
|
3341
|
-
|
3342
|
-
|
3343
|
-
|
3344
|
-
|
3345
|
-
|
3378
|
+
/**
|
3379
|
+
* 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.
|
3380
|
+
* Note if you encounter an error and want it to retry once, then you must use .retry(2);
|
3381
|
+
*
|
3382
|
+
* @example
|
3383
|
+
* var res = retried = retry.repeat();
|
3384
|
+
* var res = retried = retry.repeat(2);
|
3385
|
+
* @param {Number} [retryCount] Number of times to retry the sequence. If not provided, retry the sequence indefinitely.
|
3386
|
+
* @returns {Observable} An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.
|
3387
|
+
*/
|
3388
|
+
observableProto.retry = function (retryCount) {
|
3389
|
+
return enumerableRepeat(this, retryCount).catchException();
|
3390
|
+
};
|
3346
3391
|
|
3347
3392
|
/**
|
3348
3393
|
* Applies an accumulator function over an observable sequence and returns each intermediate result. The optional seed value is used as the initial accumulator value.
|
@@ -3907,7 +3952,7 @@
|
|
3907
3952
|
* @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences
|
3908
3953
|
* and that at any point in time produces the elements of the most recent inner observable sequence that has been received.
|
3909
3954
|
*/
|
3910
|
-
observableProto.selectSwitch = observableProto.flatMapLatest = function (selector, thisArg) {
|
3955
|
+
observableProto.selectSwitch = observableProto.flatMapLatest = observableProto.switchMap = function (selector, thisArg) {
|
3911
3956
|
return this.select(selector, thisArg).switchLatest();
|
3912
3957
|
};
|
3913
3958
|
|
@@ -4056,6 +4101,116 @@
|
|
4056
4101
|
});
|
4057
4102
|
};
|
4058
4103
|
|
4104
|
+
/*
|
4105
|
+
* Performs a exclusive waiting for the first to finish before subscribing to another observable.
|
4106
|
+
* Observables that come in between subscriptions will be dropped on the floor.
|
4107
|
+
* @returns {Observable} A exclusive observable with only the results that happen when subscribed.
|
4108
|
+
*/
|
4109
|
+
observableProto.exclusive = function () {
|
4110
|
+
var sources = this;
|
4111
|
+
return new AnonymousObservable(function (observer) {
|
4112
|
+
var hasCurrent = false,
|
4113
|
+
isStopped = false,
|
4114
|
+
m = new SingleAssignmentDisposable(),
|
4115
|
+
g = new CompositeDisposable();
|
4116
|
+
|
4117
|
+
g.add(m);
|
4118
|
+
|
4119
|
+
m.setDisposable(sources.subscribe(
|
4120
|
+
function (innerSource) {
|
4121
|
+
if (!hasCurrent) {
|
4122
|
+
hasCurrent = true;
|
4123
|
+
|
4124
|
+
isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
|
4125
|
+
|
4126
|
+
var innerSubscription = new SingleAssignmentDisposable();
|
4127
|
+
g.add(innerSubscription);
|
4128
|
+
|
4129
|
+
innerSubscription.setDisposable(innerSource.subscribe(
|
4130
|
+
observer.onNext.bind(observer),
|
4131
|
+
observer.onError.bind(observer),
|
4132
|
+
function () {
|
4133
|
+
g.remove(innerSubscription);
|
4134
|
+
hasCurrent = false;
|
4135
|
+
if (isStopped && g.length === 1) {
|
4136
|
+
observer.onCompleted();
|
4137
|
+
}
|
4138
|
+
}));
|
4139
|
+
}
|
4140
|
+
},
|
4141
|
+
observer.onError.bind(observer),
|
4142
|
+
function () {
|
4143
|
+
isStopped = true;
|
4144
|
+
if (!hasCurrent && g.length === 1) {
|
4145
|
+
observer.onCompleted();
|
4146
|
+
}
|
4147
|
+
}));
|
4148
|
+
|
4149
|
+
return g;
|
4150
|
+
});
|
4151
|
+
};
|
4152
|
+
/*
|
4153
|
+
* Performs a exclusive map waiting for the first to finish before subscribing to another observable.
|
4154
|
+
* Observables that come in between subscriptions will be dropped on the floor.
|
4155
|
+
* @param {Function} selector Selector to invoke for every item in the current subscription.
|
4156
|
+
* @param {Any} [thisArg] An optional context to invoke with the selector parameter.
|
4157
|
+
* @returns {Observable} An exclusive observable with only the results that happen when subscribed.
|
4158
|
+
*/
|
4159
|
+
observableProto.exclusiveMap = function (selector, thisArg) {
|
4160
|
+
var sources = this;
|
4161
|
+
return new AnonymousObservable(function (observer) {
|
4162
|
+
var index = 0,
|
4163
|
+
hasCurrent = false,
|
4164
|
+
isStopped = true,
|
4165
|
+
m = new SingleAssignmentDisposable(),
|
4166
|
+
g = new CompositeDisposable();
|
4167
|
+
|
4168
|
+
g.add(m);
|
4169
|
+
|
4170
|
+
m.setDisposable(sources.subscribe(
|
4171
|
+
function (innerSource) {
|
4172
|
+
|
4173
|
+
if (!hasCurrent) {
|
4174
|
+
hasCurrent = true;
|
4175
|
+
|
4176
|
+
innerSubscription = new SingleAssignmentDisposable();
|
4177
|
+
g.add(innerSubscription);
|
4178
|
+
|
4179
|
+
isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
|
4180
|
+
|
4181
|
+
innerSubscription.setDisposable(innerSource.subscribe(
|
4182
|
+
function (x) {
|
4183
|
+
var result;
|
4184
|
+
try {
|
4185
|
+
result = selector.call(thisArg, x, index++, innerSource);
|
4186
|
+
} catch (e) {
|
4187
|
+
observer.onError(e);
|
4188
|
+
return;
|
4189
|
+
}
|
4190
|
+
|
4191
|
+
observer.onNext(result);
|
4192
|
+
},
|
4193
|
+
observer.onError.bind(observer),
|
4194
|
+
function () {
|
4195
|
+
g.remove(innerSubscription);
|
4196
|
+
hasCurrent = false;
|
4197
|
+
|
4198
|
+
if (isStopped && g.length === 1) {
|
4199
|
+
observer.onCompleted();
|
4200
|
+
}
|
4201
|
+
}));
|
4202
|
+
}
|
4203
|
+
},
|
4204
|
+
observer.onError.bind(observer),
|
4205
|
+
function () {
|
4206
|
+
isStopped = true;
|
4207
|
+
if (g.length === 1 && !hasCurrent) {
|
4208
|
+
observer.onCompleted();
|
4209
|
+
}
|
4210
|
+
}));
|
4211
|
+
return g;
|
4212
|
+
});
|
4213
|
+
};
|
4059
4214
|
var AnonymousObservable = Rx.AnonymousObservable = (function (__super__) {
|
4060
4215
|
inherits(AnonymousObservable, __super__);
|
4061
4216
|
|
@@ -4076,25 +4231,21 @@
|
|
4076
4231
|
}
|
4077
4232
|
|
4078
4233
|
function s(observer) {
|
4079
|
-
var
|
4080
|
-
if (currentThreadScheduler.scheduleRequired()) {
|
4081
|
-
currentThreadScheduler.schedule(function () {
|
4082
|
-
try {
|
4083
|
-
autoDetachObserver.setDisposable(fixSubscriber(subscribe(autoDetachObserver)));
|
4084
|
-
} catch (e) {
|
4085
|
-
if (!autoDetachObserver.fail(e)) {
|
4086
|
-
throw e;
|
4087
|
-
}
|
4088
|
-
}
|
4089
|
-
});
|
4090
|
-
} else {
|
4234
|
+
var setDisposable = function () {
|
4091
4235
|
try {
|
4092
4236
|
autoDetachObserver.setDisposable(fixSubscriber(subscribe(autoDetachObserver)));
|
4093
4237
|
} catch (e) {
|
4094
4238
|
if (!autoDetachObserver.fail(e)) {
|
4095
4239
|
throw e;
|
4096
|
-
}
|
4240
|
+
}
|
4097
4241
|
}
|
4242
|
+
};
|
4243
|
+
|
4244
|
+
var autoDetachObserver = new AutoDetachObserver(observer);
|
4245
|
+
if (currentThreadScheduler.scheduleRequired()) {
|
4246
|
+
currentThreadScheduler.schedule(setDisposable);
|
4247
|
+
} else {
|
4248
|
+
setDisposable();
|
4098
4249
|
}
|
4099
4250
|
|
4100
4251
|
return autoDetachObserver;
|