rxjs-rails 2.3.11 → 2.3.14
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 +54 -66
- data/vendor/assets/javascripts/rx.aggregates.min.js +1 -1
- data/vendor/assets/javascripts/rx.all.compat.js +326 -359
- data/vendor/assets/javascripts/rx.all.compat.min.js +3 -3
- data/vendor/assets/javascripts/rx.all.js +326 -359
- data/vendor/assets/javascripts/rx.all.min.js +3 -3
- data/vendor/assets/javascripts/rx.async.compat.js +21 -33
- data/vendor/assets/javascripts/rx.async.compat.min.js +1 -1
- data/vendor/assets/javascripts/rx.async.js +21 -33
- data/vendor/assets/javascripts/rx.async.min.js +1 -1
- data/vendor/assets/javascripts/rx.compat.js +242 -363
- data/vendor/assets/javascripts/rx.compat.min.js +2 -2
- data/vendor/assets/javascripts/rx.experimental.js +112 -0
- data/vendor/assets/javascripts/rx.experimental.min.js +1 -1
- data/vendor/assets/javascripts/rx.js +242 -363
- data/vendor/assets/javascripts/rx.lite.compat.js +184 -295
- data/vendor/assets/javascripts/rx.lite.compat.min.js +2 -2
- data/vendor/assets/javascripts/rx.lite.js +184 -295
- 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.js +269 -252
- data/vendor/assets/javascripts/rx.testing.min.js +1 -1
- data/vendor/assets/javascripts/rx.time.js +1 -1
- data/vendor/assets/javascripts/rx.time.min.js +1 -1
- metadata +2 -2
@@ -307,7 +307,7 @@
|
|
307
307
|
}
|
308
308
|
}
|
309
309
|
var size = 0;
|
310
|
-
result = true;
|
310
|
+
var result = true;
|
311
311
|
|
312
312
|
// add `a` and `b` to the stack of traversed objects
|
313
313
|
stackA.push(a);
|
@@ -860,30 +860,30 @@ if (!Array.prototype.forEach) {
|
|
860
860
|
});
|
861
861
|
};
|
862
862
|
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
863
|
+
var ScheduledItem = Rx.internals.ScheduledItem = function (scheduler, state, action, dueTime, comparer) {
|
864
|
+
this.scheduler = scheduler;
|
865
|
+
this.state = state;
|
866
|
+
this.action = action;
|
867
|
+
this.dueTime = dueTime;
|
868
|
+
this.comparer = comparer || defaultSubComparer;
|
869
|
+
this.disposable = new SingleAssignmentDisposable();
|
870
|
+
}
|
871
871
|
|
872
|
-
|
873
|
-
|
874
|
-
|
872
|
+
ScheduledItem.prototype.invoke = function () {
|
873
|
+
this.disposable.setDisposable(this.invokeCore());
|
874
|
+
};
|
875
875
|
|
876
|
-
|
877
|
-
|
878
|
-
|
876
|
+
ScheduledItem.prototype.compareTo = function (other) {
|
877
|
+
return this.comparer(this.dueTime, other.dueTime);
|
878
|
+
};
|
879
879
|
|
880
|
-
|
881
|
-
|
882
|
-
|
880
|
+
ScheduledItem.prototype.isCancelled = function () {
|
881
|
+
return this.disposable.isDisposed;
|
882
|
+
};
|
883
883
|
|
884
|
-
|
885
|
-
|
886
|
-
|
884
|
+
ScheduledItem.prototype.invokeCore = function () {
|
885
|
+
return this.action(this.scheduler, this.state);
|
886
|
+
};
|
887
887
|
|
888
888
|
/** Provides a set of static properties to access commonly used schedulers. */
|
889
889
|
var Scheduler = Rx.Scheduler = (function () {
|
@@ -895,54 +895,6 @@ if (!Array.prototype.forEach) {
|
|
895
895
|
this._scheduleAbsolute = scheduleAbsolute;
|
896
896
|
}
|
897
897
|
|
898
|
-
function invokeRecImmediate(scheduler, pair) {
|
899
|
-
var state = pair.first, action = pair.second, group = new CompositeDisposable(),
|
900
|
-
recursiveAction = function (state1) {
|
901
|
-
action(state1, function (state2) {
|
902
|
-
var isAdded = false, isDone = false,
|
903
|
-
d = scheduler.scheduleWithState(state2, function (scheduler1, state3) {
|
904
|
-
if (isAdded) {
|
905
|
-
group.remove(d);
|
906
|
-
} else {
|
907
|
-
isDone = true;
|
908
|
-
}
|
909
|
-
recursiveAction(state3);
|
910
|
-
return disposableEmpty;
|
911
|
-
});
|
912
|
-
if (!isDone) {
|
913
|
-
group.add(d);
|
914
|
-
isAdded = true;
|
915
|
-
}
|
916
|
-
});
|
917
|
-
};
|
918
|
-
recursiveAction(state);
|
919
|
-
return group;
|
920
|
-
}
|
921
|
-
|
922
|
-
function invokeRecDate(scheduler, pair, method) {
|
923
|
-
var state = pair.first, action = pair.second, group = new CompositeDisposable(),
|
924
|
-
recursiveAction = function (state1) {
|
925
|
-
action(state1, function (state2, dueTime1) {
|
926
|
-
var isAdded = false, isDone = false,
|
927
|
-
d = scheduler[method].call(scheduler, state2, dueTime1, function (scheduler1, state3) {
|
928
|
-
if (isAdded) {
|
929
|
-
group.remove(d);
|
930
|
-
} else {
|
931
|
-
isDone = true;
|
932
|
-
}
|
933
|
-
recursiveAction(state3);
|
934
|
-
return disposableEmpty;
|
935
|
-
});
|
936
|
-
if (!isDone) {
|
937
|
-
group.add(d);
|
938
|
-
isAdded = true;
|
939
|
-
}
|
940
|
-
});
|
941
|
-
};
|
942
|
-
recursiveAction(state);
|
943
|
-
return group;
|
944
|
-
}
|
945
|
-
|
946
898
|
function invokeAction(scheduler, action) {
|
947
899
|
action();
|
948
900
|
return disposableEmpty;
|
@@ -1194,34 +1146,34 @@ if (!Array.prototype.forEach) {
|
|
1194
1146
|
};
|
1195
1147
|
}(Scheduler.prototype));
|
1196
1148
|
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1149
|
+
var SchedulePeriodicRecursive = Rx.internals.SchedulePeriodicRecursive = (function () {
|
1150
|
+
function tick(command, recurse) {
|
1151
|
+
recurse(0, this._period);
|
1152
|
+
try {
|
1153
|
+
this._state = this._action(this._state);
|
1154
|
+
} catch (e) {
|
1155
|
+
this._cancel.dispose();
|
1156
|
+
throw e;
|
1157
|
+
}
|
1158
|
+
}
|
1207
1159
|
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1160
|
+
function SchedulePeriodicRecursive(scheduler, state, period, action) {
|
1161
|
+
this._scheduler = scheduler;
|
1162
|
+
this._state = state;
|
1163
|
+
this._period = period;
|
1164
|
+
this._action = action;
|
1165
|
+
}
|
1214
1166
|
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1167
|
+
SchedulePeriodicRecursive.prototype.start = function () {
|
1168
|
+
var d = new SingleAssignmentDisposable();
|
1169
|
+
this._cancel = d;
|
1170
|
+
d.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0, this._period, tick.bind(this)));
|
1219
1171
|
|
1220
|
-
|
1221
|
-
|
1172
|
+
return d;
|
1173
|
+
};
|
1222
1174
|
|
1223
|
-
|
1224
|
-
|
1175
|
+
return SchedulePeriodicRecursive;
|
1176
|
+
}());
|
1225
1177
|
|
1226
1178
|
/**
|
1227
1179
|
* Gets a scheduler that schedules work immediately on the current thread.
|
@@ -1461,87 +1413,77 @@ if (!Array.prototype.forEach) {
|
|
1461
1413
|
return new Scheduler(defaultNow, scheduleNow, scheduleRelative, scheduleAbsolute);
|
1462
1414
|
})();
|
1463
1415
|
|
1464
|
-
|
1465
|
-
var CatchScheduler = (function (_super) {
|
1416
|
+
var CatchScheduler = (function (__super__) {
|
1466
1417
|
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
function scheduleNow(state, action) {
|
1472
|
-
return this._scheduler.scheduleWithState(state, this._wrap(action));
|
1473
|
-
}
|
1418
|
+
function scheduleNow(state, action) {
|
1419
|
+
return this._scheduler.scheduleWithState(state, this._wrap(action));
|
1420
|
+
}
|
1474
1421
|
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1422
|
+
function scheduleRelative(state, dueTime, action) {
|
1423
|
+
return this._scheduler.scheduleWithRelativeAndState(state, dueTime, this._wrap(action));
|
1424
|
+
}
|
1478
1425
|
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1426
|
+
function scheduleAbsolute(state, dueTime, action) {
|
1427
|
+
return this._scheduler.scheduleWithAbsoluteAndState(state, dueTime, this._wrap(action));
|
1428
|
+
}
|
1482
1429
|
|
1483
|
-
|
1430
|
+
inherits(CatchScheduler, __super__);
|
1484
1431
|
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
}
|
1432
|
+
function CatchScheduler(scheduler, handler) {
|
1433
|
+
this._scheduler = scheduler;
|
1434
|
+
this._handler = handler;
|
1435
|
+
this._recursiveOriginal = null;
|
1436
|
+
this._recursiveWrapper = null;
|
1437
|
+
__super__.call(this, this._scheduler.now.bind(this._scheduler), scheduleNow, scheduleRelative, scheduleAbsolute);
|
1438
|
+
}
|
1493
1439
|
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
};
|
1440
|
+
CatchScheduler.prototype._clone = function (scheduler) {
|
1441
|
+
return new CatchScheduler(scheduler, this._handler);
|
1442
|
+
};
|
1498
1443
|
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
};
|
1444
|
+
CatchScheduler.prototype._wrap = function (action) {
|
1445
|
+
var parent = this;
|
1446
|
+
return function (self, state) {
|
1447
|
+
try {
|
1448
|
+
return action(parent._getRecursiveWrapper(self), state);
|
1449
|
+
} catch (e) {
|
1450
|
+
if (!parent._handler(e)) { throw e; }
|
1451
|
+
return disposableEmpty;
|
1452
|
+
}
|
1453
|
+
};
|
1454
|
+
};
|
1511
1455
|
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
};
|
1456
|
+
CatchScheduler.prototype._getRecursiveWrapper = function (scheduler) {
|
1457
|
+
if (this._recursiveOriginal !== scheduler) {
|
1458
|
+
this._recursiveOriginal = scheduler;
|
1459
|
+
var wrapper = this._clone(scheduler);
|
1460
|
+
wrapper._recursiveOriginal = scheduler;
|
1461
|
+
wrapper._recursiveWrapper = wrapper;
|
1462
|
+
this._recursiveWrapper = wrapper;
|
1463
|
+
}
|
1464
|
+
return this._recursiveWrapper;
|
1465
|
+
};
|
1523
1466
|
|
1524
|
-
|
1525
|
-
|
1526
|
-
var self = this, failed = false, d = new SingleAssignmentDisposable();
|
1467
|
+
CatchScheduler.prototype.schedulePeriodicWithState = function (state, period, action) {
|
1468
|
+
var self = this, failed = false, d = new SingleAssignmentDisposable();
|
1527
1469
|
|
1528
|
-
|
1529
|
-
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1470
|
+
d.setDisposable(this._scheduler.schedulePeriodicWithState(state, period, function (state1) {
|
1471
|
+
if (failed) { return null; }
|
1472
|
+
try {
|
1473
|
+
return action(state1);
|
1474
|
+
} catch (e) {
|
1475
|
+
failed = true;
|
1476
|
+
if (!self._handler(e)) { throw e; }
|
1477
|
+
d.dispose();
|
1478
|
+
return null;
|
1479
|
+
}
|
1480
|
+
}));
|
1539
1481
|
|
1540
|
-
|
1541
|
-
|
1482
|
+
return d;
|
1483
|
+
};
|
1542
1484
|
|
1543
|
-
|
1544
|
-
|
1485
|
+
return CatchScheduler;
|
1486
|
+
}(Scheduler));
|
1545
1487
|
|
1546
1488
|
/**
|
1547
1489
|
* Represents a notification to an observer.
|
@@ -1620,14 +1562,14 @@ if (!Array.prototype.forEach) {
|
|
1620
1562
|
function _acceptObservable(observer) { return observer.onError(this.exception); }
|
1621
1563
|
function toString () { return 'OnError(' + this.exception + ')'; }
|
1622
1564
|
|
1623
|
-
return function (
|
1565
|
+
return function (e) {
|
1624
1566
|
var notification = new Notification('E');
|
1625
|
-
notification.exception =
|
1567
|
+
notification.exception = e;
|
1626
1568
|
notification._accept = _accept;
|
1627
1569
|
notification._acceptObservable = _acceptObservable;
|
1628
1570
|
notification.toString = toString;
|
1629
1571
|
return notification;
|
1630
|
-
|
1572
|
+
};
|
1631
1573
|
}());
|
1632
1574
|
|
1633
1575
|
/**
|
@@ -1636,17 +1578,17 @@ if (!Array.prototype.forEach) {
|
|
1636
1578
|
*/
|
1637
1579
|
var notificationCreateOnCompleted = Notification.createOnCompleted = (function () {
|
1638
1580
|
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1581
|
+
function _accept (onNext, onError, onCompleted) { return onCompleted(); }
|
1582
|
+
function _acceptObservable(observer) { return observer.onCompleted(); }
|
1583
|
+
function toString () { return 'OnCompleted()'; }
|
1642
1584
|
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1585
|
+
return function () {
|
1586
|
+
var notification = new Notification('C');
|
1587
|
+
notification._accept = _accept;
|
1588
|
+
notification._acceptObservable = _acceptObservable;
|
1589
|
+
notification.toString = toString;
|
1590
|
+
return notification;
|
1591
|
+
};
|
1650
1592
|
}());
|
1651
1593
|
|
1652
1594
|
var Enumerator = Rx.internals.Enumerator = function (next) {
|
@@ -2380,7 +2322,7 @@ if (!Array.prototype.forEach) {
|
|
2380
2322
|
* @param {Any} [thisArg] The context to use calling the mapFn if provided.
|
2381
2323
|
* @param {Scheduler} [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread.
|
2382
2324
|
*/
|
2383
|
-
Observable.from = function (iterable, mapFn, thisArg, scheduler) {
|
2325
|
+
var observableFrom = Observable.from = function (iterable, mapFn, thisArg, scheduler) {
|
2384
2326
|
if (iterable == null) {
|
2385
2327
|
throw new Error('iterable cannot be null.')
|
2386
2328
|
}
|
@@ -2398,7 +2340,13 @@ if (!Array.prototype.forEach) {
|
|
2398
2340
|
if (i < len || objIsIterable) {
|
2399
2341
|
var result;
|
2400
2342
|
if (objIsIterable) {
|
2401
|
-
var next
|
2343
|
+
var next;
|
2344
|
+
try {
|
2345
|
+
next = it.next();
|
2346
|
+
} catch (e) {
|
2347
|
+
observer.onError(e);
|
2348
|
+
return;
|
2349
|
+
}
|
2402
2350
|
if (next.done) {
|
2403
2351
|
observer.onCompleted();
|
2404
2352
|
return;
|
@@ -2406,7 +2354,7 @@ if (!Array.prototype.forEach) {
|
|
2406
2354
|
|
2407
2355
|
result = next.value;
|
2408
2356
|
} else {
|
2409
|
-
result = list[i];
|
2357
|
+
result = !!list.charAt ? list.charAt(i) : list[i];
|
2410
2358
|
}
|
2411
2359
|
|
2412
2360
|
if (mapFn && isCallable(mapFn)) {
|
@@ -3688,47 +3636,50 @@ if (!Array.prototype.forEach) {
|
|
3688
3636
|
});
|
3689
3637
|
};
|
3690
3638
|
|
3691
|
-
|
3692
|
-
|
3693
|
-
|
3694
|
-
|
3695
|
-
|
3696
|
-
|
3639
|
+
function concatMap(source, selector, thisArg) {
|
3640
|
+
return source.map(function (x, i) {
|
3641
|
+
var result = selector.call(thisArg, x, i, source);
|
3642
|
+
isPromise(result) && (result = observableFromPromise(result));
|
3643
|
+
(Array.isArray(result) || isIterable(result)) && (result = observableFrom(result));
|
3644
|
+
return result;
|
3645
|
+
}).concatAll();
|
3646
|
+
}
|
3697
3647
|
|
3698
|
-
|
3699
|
-
|
3700
|
-
|
3701
|
-
|
3702
|
-
|
3703
|
-
|
3704
|
-
|
3705
|
-
|
3706
|
-
|
3707
|
-
|
3708
|
-
|
3709
|
-
|
3710
|
-
|
3711
|
-
|
3712
|
-
|
3713
|
-
|
3714
|
-
|
3715
|
-
|
3716
|
-
|
3717
|
-
|
3718
|
-
|
3719
|
-
|
3720
|
-
|
3721
|
-
|
3722
|
-
|
3723
|
-
|
3724
|
-
|
3725
|
-
|
3726
|
-
|
3727
|
-
}
|
3728
|
-
|
3729
|
-
|
3730
|
-
|
3731
|
-
|
3648
|
+
/**
|
3649
|
+
* One of the Following:
|
3650
|
+
* Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
|
3651
|
+
*
|
3652
|
+
* @example
|
3653
|
+
* var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); });
|
3654
|
+
* Or:
|
3655
|
+
* Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
|
3656
|
+
*
|
3657
|
+
* var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
|
3658
|
+
* Or:
|
3659
|
+
* Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
|
3660
|
+
*
|
3661
|
+
* var res = source.concatMap(Rx.Observable.fromArray([1,2,3]));
|
3662
|
+
* @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the
|
3663
|
+
* source sequence onto which could be either an observable or Promise.
|
3664
|
+
* @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
|
3665
|
+
* @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
|
+
*/
|
3667
|
+
observableProto.selectConcat = observableProto.concatMap = function (selector, resultSelector, thisArg) {
|
3668
|
+
if (typeof selector === 'function' && typeof resultSelector === 'function') {
|
3669
|
+
return this.concatMap(function (x, i) {
|
3670
|
+
var selectorResult = selector(x, i);
|
3671
|
+
isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult));
|
3672
|
+
(Array.isArray(selectorResult) || isIterable(selectorResult)) && (selectorResult = observableFrom(selectorResult));
|
3673
|
+
|
3674
|
+
return selectorResult.map(function (y, i2) {
|
3675
|
+
return resultSelector(x, y, i, i2);
|
3676
|
+
});
|
3677
|
+
});
|
3678
|
+
}
|
3679
|
+
return typeof selector === 'function' ?
|
3680
|
+
concatMap(this, selector, thisArg) :
|
3681
|
+
concatMap(this, function () { return selector; });
|
3682
|
+
};
|
3732
3683
|
|
3733
3684
|
/**
|
3734
3685
|
* Projects each notification of an observable sequence to an observable sequence and concats the resulting observable sequences into one observable sequence.
|
@@ -4010,48 +3961,50 @@ if (!Array.prototype.forEach) {
|
|
4010
3961
|
return this.map(function (x) { return x[prop]; });
|
4011
3962
|
};
|
4012
3963
|
|
4013
|
-
|
4014
|
-
|
4015
|
-
|
4016
|
-
|
4017
|
-
|
4018
|
-
|
3964
|
+
function flatMap(source, selector, thisArg) {
|
3965
|
+
return source.map(function (x, i) {
|
3966
|
+
var result = selector.call(thisArg, x, i, source);
|
3967
|
+
isPromise(result) && (result = observableFromPromise(result));
|
3968
|
+
(Array.isArray(result) || isIterable(result)) && (result = observableFrom(result));
|
3969
|
+
return result;
|
3970
|
+
}).mergeObservable();
|
3971
|
+
}
|
4019
3972
|
|
4020
|
-
|
4021
|
-
|
4022
|
-
|
4023
|
-
|
4024
|
-
|
4025
|
-
|
4026
|
-
|
4027
|
-
|
4028
|
-
|
4029
|
-
|
4030
|
-
|
4031
|
-
|
4032
|
-
|
4033
|
-
|
4034
|
-
|
4035
|
-
|
4036
|
-
|
4037
|
-
|
4038
|
-
|
4039
|
-
|
4040
|
-
|
4041
|
-
|
4042
|
-
|
4043
|
-
|
4044
|
-
|
4045
|
-
|
4046
|
-
|
4047
|
-
|
4048
|
-
|
4049
|
-
|
4050
|
-
|
4051
|
-
|
4052
|
-
|
4053
|
-
|
4054
|
-
|
3973
|
+
/**
|
3974
|
+
* One of the Following:
|
3975
|
+
* Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
|
3976
|
+
*
|
3977
|
+
* @example
|
3978
|
+
* var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); });
|
3979
|
+
* Or:
|
3980
|
+
* Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
|
3981
|
+
*
|
3982
|
+
* var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
|
3983
|
+
* Or:
|
3984
|
+
* Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
|
3985
|
+
*
|
3986
|
+
* var res = source.selectMany(Rx.Observable.fromArray([1,2,3]));
|
3987
|
+
* @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the source sequence onto which could be either an observable or Promise.
|
3988
|
+
* @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
|
3989
|
+
* @param {Any} [thisArg] Object to use as this when executing callback.
|
3990
|
+
* @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
|
+
*/
|
3992
|
+
observableProto.selectMany = observableProto.flatMap = function (selector, resultSelector, thisArg) {
|
3993
|
+
if (typeof selector === 'function' && typeof resultSelector === 'function') {
|
3994
|
+
return this.flatMap(function (x, i) {
|
3995
|
+
var selectorResult = selector(x, i);
|
3996
|
+
isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult));
|
3997
|
+
(Array.isArray(selectorResult) || isIterable(selectorResult)) && (selectorResult = observableFrom(selectorResult));
|
3998
|
+
|
3999
|
+
return selectorResult.map(function (y, i2) {
|
4000
|
+
return resultSelector(x, y, i, i2);
|
4001
|
+
});
|
4002
|
+
}, thisArg);
|
4003
|
+
}
|
4004
|
+
return typeof selector === 'function' ?
|
4005
|
+
flatMap(this, selector, thisArg) :
|
4006
|
+
flatMap(this, function () { return selector; });
|
4007
|
+
};
|
4055
4008
|
|
4056
4009
|
/**
|
4057
4010
|
* Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
|
@@ -4305,46 +4258,40 @@ if (!Array.prototype.forEach) {
|
|
4305
4258
|
return x[0];
|
4306
4259
|
}
|
4307
4260
|
|
4308
|
-
|
4309
|
-
|
4310
|
-
|
4311
|
-
|
4312
|
-
|
4313
|
-
|
4314
|
-
|
4315
|
-
|
4316
|
-
|
4317
|
-
|
4318
|
-
|
4319
|
-
|
4320
|
-
|
4321
|
-
|
4322
|
-
|
4323
|
-
|
4324
|
-
|
4325
|
-
|
4326
|
-
}
|
4327
|
-
return hasSeed ? this.scan(seed, accumulator).startWith(seed).finalValue() : this.scan(accumulator).finalValue();
|
4328
|
-
};
|
4261
|
+
/**
|
4262
|
+
* 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
|
+
* For aggregation behavior with incremental intermediate results, see Observable.scan.
|
4264
|
+
* @param {Mixed} [seed] The initial accumulator value.
|
4265
|
+
* @param {Function} accumulator An accumulator function to be invoked on each element.
|
4266
|
+
* @returns {Observable} An observable sequence containing a single element with the final accumulator value.
|
4267
|
+
*/
|
4268
|
+
observableProto.aggregate = function () {
|
4269
|
+
var seed, hasSeed, accumulator;
|
4270
|
+
if (arguments.length === 2) {
|
4271
|
+
seed = arguments[0];
|
4272
|
+
hasSeed = true;
|
4273
|
+
accumulator = arguments[1];
|
4274
|
+
} else {
|
4275
|
+
accumulator = arguments[0];
|
4276
|
+
}
|
4277
|
+
return hasSeed ? this.scan(seed, accumulator).startWith(seed).finalValue() : this.scan(accumulator).finalValue();
|
4278
|
+
};
|
4329
4279
|
|
4330
|
-
|
4331
|
-
|
4332
|
-
|
4333
|
-
|
4334
|
-
|
4335
|
-
|
4336
|
-
|
4337
|
-
|
4338
|
-
|
4339
|
-
|
4340
|
-
|
4341
|
-
|
4342
|
-
|
4343
|
-
|
4344
|
-
|
4345
|
-
}
|
4346
|
-
return hasSeed ? this.scan(seed, accumulator).startWith(seed).finalValue() : this.scan(accumulator).finalValue();
|
4347
|
-
};
|
4280
|
+
/**
|
4281
|
+
* 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.
|
4282
|
+
* For aggregation behavior with incremental intermediate results, see Observable.scan.
|
4283
|
+
* @param {Function} accumulator An accumulator function to be invoked on each element.
|
4284
|
+
* @param {Any} [seed] The initial accumulator value.
|
4285
|
+
* @returns {Observable} An observable sequence containing a single element with the final accumulator value.
|
4286
|
+
*/
|
4287
|
+
observableProto.reduce = function (accumulator) {
|
4288
|
+
var seed, hasSeed;
|
4289
|
+
if (arguments.length === 2) {
|
4290
|
+
hasSeed = true;
|
4291
|
+
seed = arguments[1];
|
4292
|
+
}
|
4293
|
+
return hasSeed ? this.scan(seed, accumulator).startWith(seed).finalValue() : this.scan(accumulator).finalValue();
|
4294
|
+
};
|
4348
4295
|
|
4349
4296
|
/**
|
4350
4297
|
* Determines whether any element of an observable sequence satisfies a condition if present, else if any items are in the sequence.
|
@@ -4551,33 +4498,27 @@ if (!Array.prototype.forEach) {
|
|
4551
4498
|
});
|
4552
4499
|
};
|
4553
4500
|
|
4554
|
-
|
4555
|
-
|
4556
|
-
|
4557
|
-
|
4558
|
-
|
4559
|
-
|
4560
|
-
|
4561
|
-
|
4562
|
-
|
4563
|
-
|
4564
|
-
return
|
4565
|
-
|
4566
|
-
|
4567
|
-
|
4568
|
-
|
4569
|
-
|
4570
|
-
|
4571
|
-
|
4572
|
-
|
4573
|
-
|
4574
|
-
|
4575
|
-
if (s.count === 0) {
|
4576
|
-
throw new Error('The input sequence was empty');
|
4577
|
-
}
|
4578
|
-
return s.sum / s.count;
|
4579
|
-
});
|
4580
|
-
};
|
4501
|
+
/**
|
4502
|
+
* 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.
|
4503
|
+
* @param {Function} [selector] A transform function to apply to each element.
|
4504
|
+
* @param {Any} [thisArg] Object to use as this when executing callback.
|
4505
|
+
* @returns {Observable} An observable sequence containing a single element with the average of the sequence of values.
|
4506
|
+
*/
|
4507
|
+
observableProto.average = function (keySelector, thisArg) {
|
4508
|
+
return keySelector && isFunction(keySelector) ?
|
4509
|
+
this.select(keySelector, thisArg).average() :
|
4510
|
+
this.scan({sum: 0, count: 0 }, function (prev, cur) {
|
4511
|
+
return {
|
4512
|
+
sum: prev.sum + cur,
|
4513
|
+
count: prev.count + 1
|
4514
|
+
};
|
4515
|
+
}).finalValue().map(function (s) {
|
4516
|
+
if (s.count === 0) {
|
4517
|
+
throw new Error('The input sequence was empty');
|
4518
|
+
}
|
4519
|
+
return s.sum / s.count;
|
4520
|
+
});
|
4521
|
+
};
|
4581
4522
|
|
4582
4523
|
function sequenceEqualArray(first, second, comparer) {
|
4583
4524
|
return new AnonymousObservable(function (observer) {
|
@@ -4999,36 +4940,17 @@ if (!Array.prototype.forEach) {
|
|
4999
4940
|
};
|
5000
4941
|
}
|
5001
4942
|
|
5002
|
-
var fnString = 'function'
|
4943
|
+
var fnString = 'function',
|
4944
|
+
throwString = 'throw';
|
5003
4945
|
|
5004
4946
|
function toThunk(obj, ctx) {
|
5005
|
-
if (Array.isArray(obj)) {
|
5006
|
-
|
5007
|
-
}
|
5008
|
-
|
5009
|
-
if (
|
5010
|
-
|
5011
|
-
}
|
5012
|
-
|
5013
|
-
if (isGenerator(obj)) {
|
5014
|
-
return observableSpawn(obj);
|
5015
|
-
}
|
5016
|
-
|
5017
|
-
if (isObservable(obj)) {
|
5018
|
-
return observableToThunk(obj);
|
5019
|
-
}
|
5020
|
-
|
5021
|
-
if (isPromise(obj)) {
|
5022
|
-
return promiseToThunk(obj);
|
5023
|
-
}
|
5024
|
-
|
5025
|
-
if (typeof obj === fnString) {
|
5026
|
-
return obj;
|
5027
|
-
}
|
5028
|
-
|
5029
|
-
if (isObject(obj) || Array.isArray(obj)) {
|
5030
|
-
return objectToThunk.call(ctx, obj);
|
5031
|
-
}
|
4947
|
+
if (Array.isArray(obj)) { return objectToThunk.call(ctx, obj); }
|
4948
|
+
if (isGeneratorFunction(obj)) { return observableSpawn(obj.call(ctx)); }
|
4949
|
+
if (isGenerator(obj)) { return observableSpawn(obj); }
|
4950
|
+
if (isObservable(obj)) { return observableToThunk(obj); }
|
4951
|
+
if (isPromise(obj)) { return promiseToThunk(obj); }
|
4952
|
+
if (typeof obj === fnString) { return obj; }
|
4953
|
+
if (isObject(obj) || Array.isArray(obj)) { return objectToThunk.call(ctx, obj); }
|
5032
4954
|
|
5033
4955
|
return obj;
|
5034
4956
|
}
|
@@ -5080,7 +5002,7 @@ if (!Array.prototype.forEach) {
|
|
5080
5002
|
}
|
5081
5003
|
}
|
5082
5004
|
|
5083
|
-
function
|
5005
|
+
function observableToThunk(observable) {
|
5084
5006
|
return function (fn) {
|
5085
5007
|
var value, hasValue = false;
|
5086
5008
|
observable.subscribe(
|
@@ -5104,7 +5026,7 @@ if (!Array.prototype.forEach) {
|
|
5104
5026
|
}
|
5105
5027
|
|
5106
5028
|
function isObservable(obj) {
|
5107
|
-
return obj && obj.
|
5029
|
+
return obj && typeof obj.subscribe === fnString;
|
5108
5030
|
}
|
5109
5031
|
|
5110
5032
|
function isGeneratorFunction(obj) {
|
@@ -5112,7 +5034,7 @@ if (!Array.prototype.forEach) {
|
|
5112
5034
|
}
|
5113
5035
|
|
5114
5036
|
function isGenerator(obj) {
|
5115
|
-
return obj && typeof obj.next === fnString && typeof obj
|
5037
|
+
return obj && typeof obj.next === fnString && typeof obj[throwString] === fnString;
|
5116
5038
|
}
|
5117
5039
|
|
5118
5040
|
function isObject(val) {
|
@@ -5129,7 +5051,7 @@ if (!Array.prototype.forEach) {
|
|
5129
5051
|
|
5130
5052
|
return function (done) {
|
5131
5053
|
var ctx = this,
|
5132
|
-
gen =
|
5054
|
+
gen = fn;
|
5133
5055
|
|
5134
5056
|
if (isGenFun) {
|
5135
5057
|
var args = slice.call(arguments),
|
@@ -5156,7 +5078,7 @@ if (!Array.prototype.forEach) {
|
|
5156
5078
|
|
5157
5079
|
if (err) {
|
5158
5080
|
try {
|
5159
|
-
ret = gen
|
5081
|
+
ret = gen[throwString](err);
|
5160
5082
|
} catch (e) {
|
5161
5083
|
return exit(e);
|
5162
5084
|
}
|
@@ -5240,6 +5162,13 @@ if (!Array.prototype.forEach) {
|
|
5240
5162
|
}
|
5241
5163
|
};
|
5242
5164
|
|
5165
|
+
function error(err) {
|
5166
|
+
if (!err) { return; }
|
5167
|
+
timeoutScheduler.schedule(function(){
|
5168
|
+
throw err;
|
5169
|
+
});
|
5170
|
+
}
|
5171
|
+
|
5243
5172
|
/**
|
5244
5173
|
* Invokes the specified function asynchronously on the specified scheduler, surfacing the result through an observable sequence.
|
5245
5174
|
*
|
@@ -8160,7 +8089,7 @@ if (!Array.prototype.forEach) {
|
|
8160
8089
|
* @returns {Observable} The source sequence switching to the other sequence in case of a timeout.
|
8161
8090
|
*/
|
8162
8091
|
observableProto.timeout = function (dueTime, other, scheduler) {
|
8163
|
-
other || (other = observableThrow(new Error('Timeout')));
|
8092
|
+
(other == null || typeof other === 'string') && (other = observableThrow(new Error(other || 'Timeout')));
|
8164
8093
|
isScheduler(scheduler) || (scheduler = timeoutScheduler);
|
8165
8094
|
|
8166
8095
|
var source = this, schedulerMethod = dueTime instanceof Date ?
|
@@ -8824,6 +8753,44 @@ if (!Array.prototype.forEach) {
|
|
8824
8753
|
});
|
8825
8754
|
};
|
8826
8755
|
|
8756
|
+
/**
|
8757
|
+
* Executes a transducer to transform the observable sequence
|
8758
|
+
* @param {Transducer} transducer A transducer to execute
|
8759
|
+
* @returns {Observable} An Observable sequence containing the results from the transducer.
|
8760
|
+
*/
|
8761
|
+
observableProto.transduce = function(transducer) {
|
8762
|
+
var source = this;
|
8763
|
+
|
8764
|
+
function transformForObserver(observer) {
|
8765
|
+
return {
|
8766
|
+
init: function() {
|
8767
|
+
return observer;
|
8768
|
+
},
|
8769
|
+
step: function(obs, input) {
|
8770
|
+
return obs.onNext(input);
|
8771
|
+
},
|
8772
|
+
result: function(obs) {
|
8773
|
+
return obs.onCompleted();
|
8774
|
+
}
|
8775
|
+
};
|
8776
|
+
}
|
8777
|
+
|
8778
|
+
return new AnonymousObservable(function(observer) {
|
8779
|
+
var xform = transducer(transformForObserver(observer));
|
8780
|
+
return source.subscribe(
|
8781
|
+
function(v) {
|
8782
|
+
try {
|
8783
|
+
xform.step(observer, v);
|
8784
|
+
} catch (e) {
|
8785
|
+
observer.onError(e);
|
8786
|
+
}
|
8787
|
+
},
|
8788
|
+
observer.onError.bind(observer),
|
8789
|
+
function() { xform.result(observer); }
|
8790
|
+
);
|
8791
|
+
});
|
8792
|
+
};
|
8793
|
+
|
8827
8794
|
/** Provides a set of extension methods for virtual time scheduling. */
|
8828
8795
|
Rx.VirtualTimeScheduler = (function (__super__) {
|
8829
8796
|
|