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);
|
@@ -709,30 +709,30 @@
|
|
709
709
|
});
|
710
710
|
};
|
711
711
|
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
712
|
+
var ScheduledItem = Rx.internals.ScheduledItem = function (scheduler, state, action, dueTime, comparer) {
|
713
|
+
this.scheduler = scheduler;
|
714
|
+
this.state = state;
|
715
|
+
this.action = action;
|
716
|
+
this.dueTime = dueTime;
|
717
|
+
this.comparer = comparer || defaultSubComparer;
|
718
|
+
this.disposable = new SingleAssignmentDisposable();
|
719
|
+
}
|
720
720
|
|
721
|
-
|
722
|
-
|
723
|
-
|
721
|
+
ScheduledItem.prototype.invoke = function () {
|
722
|
+
this.disposable.setDisposable(this.invokeCore());
|
723
|
+
};
|
724
724
|
|
725
|
-
|
726
|
-
|
727
|
-
|
725
|
+
ScheduledItem.prototype.compareTo = function (other) {
|
726
|
+
return this.comparer(this.dueTime, other.dueTime);
|
727
|
+
};
|
728
728
|
|
729
|
-
|
730
|
-
|
731
|
-
|
729
|
+
ScheduledItem.prototype.isCancelled = function () {
|
730
|
+
return this.disposable.isDisposed;
|
731
|
+
};
|
732
732
|
|
733
|
-
|
734
|
-
|
735
|
-
|
733
|
+
ScheduledItem.prototype.invokeCore = function () {
|
734
|
+
return this.action(this.scheduler, this.state);
|
735
|
+
};
|
736
736
|
|
737
737
|
/** Provides a set of static properties to access commonly used schedulers. */
|
738
738
|
var Scheduler = Rx.Scheduler = (function () {
|
@@ -744,54 +744,6 @@
|
|
744
744
|
this._scheduleAbsolute = scheduleAbsolute;
|
745
745
|
}
|
746
746
|
|
747
|
-
function invokeRecImmediate(scheduler, pair) {
|
748
|
-
var state = pair.first, action = pair.second, group = new CompositeDisposable(),
|
749
|
-
recursiveAction = function (state1) {
|
750
|
-
action(state1, function (state2) {
|
751
|
-
var isAdded = false, isDone = false,
|
752
|
-
d = scheduler.scheduleWithState(state2, function (scheduler1, state3) {
|
753
|
-
if (isAdded) {
|
754
|
-
group.remove(d);
|
755
|
-
} else {
|
756
|
-
isDone = true;
|
757
|
-
}
|
758
|
-
recursiveAction(state3);
|
759
|
-
return disposableEmpty;
|
760
|
-
});
|
761
|
-
if (!isDone) {
|
762
|
-
group.add(d);
|
763
|
-
isAdded = true;
|
764
|
-
}
|
765
|
-
});
|
766
|
-
};
|
767
|
-
recursiveAction(state);
|
768
|
-
return group;
|
769
|
-
}
|
770
|
-
|
771
|
-
function invokeRecDate(scheduler, pair, method) {
|
772
|
-
var state = pair.first, action = pair.second, group = new CompositeDisposable(),
|
773
|
-
recursiveAction = function (state1) {
|
774
|
-
action(state1, function (state2, dueTime1) {
|
775
|
-
var isAdded = false, isDone = false,
|
776
|
-
d = scheduler[method].call(scheduler, state2, dueTime1, function (scheduler1, state3) {
|
777
|
-
if (isAdded) {
|
778
|
-
group.remove(d);
|
779
|
-
} else {
|
780
|
-
isDone = true;
|
781
|
-
}
|
782
|
-
recursiveAction(state3);
|
783
|
-
return disposableEmpty;
|
784
|
-
});
|
785
|
-
if (!isDone) {
|
786
|
-
group.add(d);
|
787
|
-
isAdded = true;
|
788
|
-
}
|
789
|
-
});
|
790
|
-
};
|
791
|
-
recursiveAction(state);
|
792
|
-
return group;
|
793
|
-
}
|
794
|
-
|
795
747
|
function invokeAction(scheduler, action) {
|
796
748
|
action();
|
797
749
|
return disposableEmpty;
|
@@ -1043,34 +995,34 @@
|
|
1043
995
|
};
|
1044
996
|
}(Scheduler.prototype));
|
1045
997
|
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
998
|
+
var SchedulePeriodicRecursive = Rx.internals.SchedulePeriodicRecursive = (function () {
|
999
|
+
function tick(command, recurse) {
|
1000
|
+
recurse(0, this._period);
|
1001
|
+
try {
|
1002
|
+
this._state = this._action(this._state);
|
1003
|
+
} catch (e) {
|
1004
|
+
this._cancel.dispose();
|
1005
|
+
throw e;
|
1006
|
+
}
|
1007
|
+
}
|
1056
1008
|
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1009
|
+
function SchedulePeriodicRecursive(scheduler, state, period, action) {
|
1010
|
+
this._scheduler = scheduler;
|
1011
|
+
this._state = state;
|
1012
|
+
this._period = period;
|
1013
|
+
this._action = action;
|
1014
|
+
}
|
1063
1015
|
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1016
|
+
SchedulePeriodicRecursive.prototype.start = function () {
|
1017
|
+
var d = new SingleAssignmentDisposable();
|
1018
|
+
this._cancel = d;
|
1019
|
+
d.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0, this._period, tick.bind(this)));
|
1068
1020
|
|
1069
|
-
|
1070
|
-
|
1021
|
+
return d;
|
1022
|
+
};
|
1071
1023
|
|
1072
|
-
|
1073
|
-
|
1024
|
+
return SchedulePeriodicRecursive;
|
1025
|
+
}());
|
1074
1026
|
|
1075
1027
|
/**
|
1076
1028
|
* Gets a scheduler that schedules work immediately on the current thread.
|
@@ -1310,87 +1262,77 @@
|
|
1310
1262
|
return new Scheduler(defaultNow, scheduleNow, scheduleRelative, scheduleAbsolute);
|
1311
1263
|
})();
|
1312
1264
|
|
1313
|
-
|
1314
|
-
var CatchScheduler = (function (_super) {
|
1315
|
-
|
1316
|
-
function localNow() {
|
1317
|
-
return this._scheduler.now();
|
1318
|
-
}
|
1265
|
+
var CatchScheduler = (function (__super__) {
|
1319
1266
|
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1267
|
+
function scheduleNow(state, action) {
|
1268
|
+
return this._scheduler.scheduleWithState(state, this._wrap(action));
|
1269
|
+
}
|
1323
1270
|
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1271
|
+
function scheduleRelative(state, dueTime, action) {
|
1272
|
+
return this._scheduler.scheduleWithRelativeAndState(state, dueTime, this._wrap(action));
|
1273
|
+
}
|
1327
1274
|
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1275
|
+
function scheduleAbsolute(state, dueTime, action) {
|
1276
|
+
return this._scheduler.scheduleWithAbsoluteAndState(state, dueTime, this._wrap(action));
|
1277
|
+
}
|
1331
1278
|
|
1332
|
-
|
1279
|
+
inherits(CatchScheduler, __super__);
|
1333
1280
|
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
}
|
1281
|
+
function CatchScheduler(scheduler, handler) {
|
1282
|
+
this._scheduler = scheduler;
|
1283
|
+
this._handler = handler;
|
1284
|
+
this._recursiveOriginal = null;
|
1285
|
+
this._recursiveWrapper = null;
|
1286
|
+
__super__.call(this, this._scheduler.now.bind(this._scheduler), scheduleNow, scheduleRelative, scheduleAbsolute);
|
1287
|
+
}
|
1342
1288
|
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
};
|
1289
|
+
CatchScheduler.prototype._clone = function (scheduler) {
|
1290
|
+
return new CatchScheduler(scheduler, this._handler);
|
1291
|
+
};
|
1347
1292
|
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
};
|
1293
|
+
CatchScheduler.prototype._wrap = function (action) {
|
1294
|
+
var parent = this;
|
1295
|
+
return function (self, state) {
|
1296
|
+
try {
|
1297
|
+
return action(parent._getRecursiveWrapper(self), state);
|
1298
|
+
} catch (e) {
|
1299
|
+
if (!parent._handler(e)) { throw e; }
|
1300
|
+
return disposableEmpty;
|
1301
|
+
}
|
1302
|
+
};
|
1303
|
+
};
|
1360
1304
|
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
};
|
1305
|
+
CatchScheduler.prototype._getRecursiveWrapper = function (scheduler) {
|
1306
|
+
if (this._recursiveOriginal !== scheduler) {
|
1307
|
+
this._recursiveOriginal = scheduler;
|
1308
|
+
var wrapper = this._clone(scheduler);
|
1309
|
+
wrapper._recursiveOriginal = scheduler;
|
1310
|
+
wrapper._recursiveWrapper = wrapper;
|
1311
|
+
this._recursiveWrapper = wrapper;
|
1312
|
+
}
|
1313
|
+
return this._recursiveWrapper;
|
1314
|
+
};
|
1372
1315
|
|
1373
|
-
|
1374
|
-
|
1375
|
-
var self = this, failed = false, d = new SingleAssignmentDisposable();
|
1316
|
+
CatchScheduler.prototype.schedulePeriodicWithState = function (state, period, action) {
|
1317
|
+
var self = this, failed = false, d = new SingleAssignmentDisposable();
|
1376
1318
|
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1319
|
+
d.setDisposable(this._scheduler.schedulePeriodicWithState(state, period, function (state1) {
|
1320
|
+
if (failed) { return null; }
|
1321
|
+
try {
|
1322
|
+
return action(state1);
|
1323
|
+
} catch (e) {
|
1324
|
+
failed = true;
|
1325
|
+
if (!self._handler(e)) { throw e; }
|
1326
|
+
d.dispose();
|
1327
|
+
return null;
|
1328
|
+
}
|
1329
|
+
}));
|
1388
1330
|
|
1389
|
-
|
1390
|
-
|
1331
|
+
return d;
|
1332
|
+
};
|
1391
1333
|
|
1392
|
-
|
1393
|
-
|
1334
|
+
return CatchScheduler;
|
1335
|
+
}(Scheduler));
|
1394
1336
|
|
1395
1337
|
/**
|
1396
1338
|
* Represents a notification to an observer.
|
@@ -1469,14 +1411,14 @@
|
|
1469
1411
|
function _acceptObservable(observer) { return observer.onError(this.exception); }
|
1470
1412
|
function toString () { return 'OnError(' + this.exception + ')'; }
|
1471
1413
|
|
1472
|
-
return function (
|
1414
|
+
return function (e) {
|
1473
1415
|
var notification = new Notification('E');
|
1474
|
-
notification.exception =
|
1416
|
+
notification.exception = e;
|
1475
1417
|
notification._accept = _accept;
|
1476
1418
|
notification._acceptObservable = _acceptObservable;
|
1477
1419
|
notification.toString = toString;
|
1478
1420
|
return notification;
|
1479
|
-
|
1421
|
+
};
|
1480
1422
|
}());
|
1481
1423
|
|
1482
1424
|
/**
|
@@ -1485,17 +1427,17 @@
|
|
1485
1427
|
*/
|
1486
1428
|
var notificationCreateOnCompleted = Notification.createOnCompleted = (function () {
|
1487
1429
|
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1430
|
+
function _accept (onNext, onError, onCompleted) { return onCompleted(); }
|
1431
|
+
function _acceptObservable(observer) { return observer.onCompleted(); }
|
1432
|
+
function toString () { return 'OnCompleted()'; }
|
1491
1433
|
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1434
|
+
return function () {
|
1435
|
+
var notification = new Notification('C');
|
1436
|
+
notification._accept = _accept;
|
1437
|
+
notification._acceptObservable = _acceptObservable;
|
1438
|
+
notification.toString = toString;
|
1439
|
+
return notification;
|
1440
|
+
};
|
1499
1441
|
}());
|
1500
1442
|
|
1501
1443
|
var Enumerator = Rx.internals.Enumerator = function (next) {
|
@@ -2229,7 +2171,7 @@
|
|
2229
2171
|
* @param {Any} [thisArg] The context to use calling the mapFn if provided.
|
2230
2172
|
* @param {Scheduler} [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread.
|
2231
2173
|
*/
|
2232
|
-
Observable.from = function (iterable, mapFn, thisArg, scheduler) {
|
2174
|
+
var observableFrom = Observable.from = function (iterable, mapFn, thisArg, scheduler) {
|
2233
2175
|
if (iterable == null) {
|
2234
2176
|
throw new Error('iterable cannot be null.')
|
2235
2177
|
}
|
@@ -2247,7 +2189,13 @@
|
|
2247
2189
|
if (i < len || objIsIterable) {
|
2248
2190
|
var result;
|
2249
2191
|
if (objIsIterable) {
|
2250
|
-
var next
|
2192
|
+
var next;
|
2193
|
+
try {
|
2194
|
+
next = it.next();
|
2195
|
+
} catch (e) {
|
2196
|
+
observer.onError(e);
|
2197
|
+
return;
|
2198
|
+
}
|
2251
2199
|
if (next.done) {
|
2252
2200
|
observer.onCompleted();
|
2253
2201
|
return;
|
@@ -2255,7 +2203,7 @@
|
|
2255
2203
|
|
2256
2204
|
result = next.value;
|
2257
2205
|
} else {
|
2258
|
-
result = list[i];
|
2206
|
+
result = !!list.charAt ? list.charAt(i) : list[i];
|
2259
2207
|
}
|
2260
2208
|
|
2261
2209
|
if (mapFn && isCallable(mapFn)) {
|
@@ -3537,47 +3485,50 @@
|
|
3537
3485
|
});
|
3538
3486
|
};
|
3539
3487
|
|
3540
|
-
|
3541
|
-
|
3542
|
-
|
3543
|
-
|
3544
|
-
|
3545
|
-
|
3488
|
+
function concatMap(source, selector, thisArg) {
|
3489
|
+
return source.map(function (x, i) {
|
3490
|
+
var result = selector.call(thisArg, x, i, source);
|
3491
|
+
isPromise(result) && (result = observableFromPromise(result));
|
3492
|
+
(Array.isArray(result) || isIterable(result)) && (result = observableFrom(result));
|
3493
|
+
return result;
|
3494
|
+
}).concatAll();
|
3495
|
+
}
|
3546
3496
|
|
3547
|
-
|
3548
|
-
|
3549
|
-
|
3550
|
-
|
3551
|
-
|
3552
|
-
|
3553
|
-
|
3554
|
-
|
3555
|
-
|
3556
|
-
|
3557
|
-
|
3558
|
-
|
3559
|
-
|
3560
|
-
|
3561
|
-
|
3562
|
-
|
3563
|
-
|
3564
|
-
|
3565
|
-
|
3566
|
-
|
3567
|
-
|
3568
|
-
|
3569
|
-
|
3570
|
-
|
3571
|
-
|
3572
|
-
|
3573
|
-
|
3574
|
-
|
3575
|
-
|
3576
|
-
}
|
3577
|
-
|
3578
|
-
|
3579
|
-
|
3580
|
-
|
3497
|
+
/**
|
3498
|
+
* One of the Following:
|
3499
|
+
* Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
|
3500
|
+
*
|
3501
|
+
* @example
|
3502
|
+
* var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); });
|
3503
|
+
* Or:
|
3504
|
+
* 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.
|
3505
|
+
*
|
3506
|
+
* var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
|
3507
|
+
* Or:
|
3508
|
+
* Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
|
3509
|
+
*
|
3510
|
+
* var res = source.concatMap(Rx.Observable.fromArray([1,2,3]));
|
3511
|
+
* @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the
|
3512
|
+
* source sequence onto which could be either an observable or Promise.
|
3513
|
+
* @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
|
3514
|
+
* @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.
|
3515
|
+
*/
|
3516
|
+
observableProto.selectConcat = observableProto.concatMap = function (selector, resultSelector, thisArg) {
|
3517
|
+
if (typeof selector === 'function' && typeof resultSelector === 'function') {
|
3518
|
+
return this.concatMap(function (x, i) {
|
3519
|
+
var selectorResult = selector(x, i);
|
3520
|
+
isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult));
|
3521
|
+
(Array.isArray(selectorResult) || isIterable(selectorResult)) && (selectorResult = observableFrom(selectorResult));
|
3522
|
+
|
3523
|
+
return selectorResult.map(function (y, i2) {
|
3524
|
+
return resultSelector(x, y, i, i2);
|
3525
|
+
});
|
3526
|
+
});
|
3527
|
+
}
|
3528
|
+
return typeof selector === 'function' ?
|
3529
|
+
concatMap(this, selector, thisArg) :
|
3530
|
+
concatMap(this, function () { return selector; });
|
3531
|
+
};
|
3581
3532
|
|
3582
3533
|
/**
|
3583
3534
|
* Projects each notification of an observable sequence to an observable sequence and concats the resulting observable sequences into one observable sequence.
|
@@ -3797,48 +3748,50 @@
|
|
3797
3748
|
}).mergeAll();
|
3798
3749
|
};
|
3799
3750
|
|
3800
|
-
|
3801
|
-
|
3802
|
-
|
3803
|
-
|
3804
|
-
|
3805
|
-
|
3751
|
+
function flatMap(source, selector, thisArg) {
|
3752
|
+
return source.map(function (x, i) {
|
3753
|
+
var result = selector.call(thisArg, x, i, source);
|
3754
|
+
isPromise(result) && (result = observableFromPromise(result));
|
3755
|
+
(Array.isArray(result) || isIterable(result)) && (result = observableFrom(result));
|
3756
|
+
return result;
|
3757
|
+
}).mergeObservable();
|
3758
|
+
}
|
3806
3759
|
|
3807
|
-
|
3808
|
-
|
3809
|
-
|
3810
|
-
|
3811
|
-
|
3812
|
-
|
3813
|
-
|
3814
|
-
|
3815
|
-
|
3816
|
-
|
3817
|
-
|
3818
|
-
|
3819
|
-
|
3820
|
-
|
3821
|
-
|
3822
|
-
|
3823
|
-
|
3824
|
-
|
3825
|
-
|
3826
|
-
|
3827
|
-
|
3828
|
-
|
3829
|
-
|
3830
|
-
|
3831
|
-
|
3832
|
-
|
3833
|
-
|
3834
|
-
|
3835
|
-
|
3836
|
-
|
3837
|
-
|
3838
|
-
|
3839
|
-
|
3840
|
-
|
3841
|
-
|
3760
|
+
/**
|
3761
|
+
* One of the Following:
|
3762
|
+
* Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
|
3763
|
+
*
|
3764
|
+
* @example
|
3765
|
+
* var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); });
|
3766
|
+
* Or:
|
3767
|
+
* 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.
|
3768
|
+
*
|
3769
|
+
* var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
|
3770
|
+
* Or:
|
3771
|
+
* Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
|
3772
|
+
*
|
3773
|
+
* var res = source.selectMany(Rx.Observable.fromArray([1,2,3]));
|
3774
|
+
* @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.
|
3775
|
+
* @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
|
3776
|
+
* @param {Any} [thisArg] Object to use as this when executing callback.
|
3777
|
+
* @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.
|
3778
|
+
*/
|
3779
|
+
observableProto.selectMany = observableProto.flatMap = function (selector, resultSelector, thisArg) {
|
3780
|
+
if (typeof selector === 'function' && typeof resultSelector === 'function') {
|
3781
|
+
return this.flatMap(function (x, i) {
|
3782
|
+
var selectorResult = selector(x, i);
|
3783
|
+
isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult));
|
3784
|
+
(Array.isArray(selectorResult) || isIterable(selectorResult)) && (selectorResult = observableFrom(selectorResult));
|
3785
|
+
|
3786
|
+
return selectorResult.map(function (y, i2) {
|
3787
|
+
return resultSelector(x, y, i, i2);
|
3788
|
+
});
|
3789
|
+
}, thisArg);
|
3790
|
+
}
|
3791
|
+
return typeof selector === 'function' ?
|
3792
|
+
flatMap(this, selector, thisArg) :
|
3793
|
+
flatMap(this, function () { return selector; });
|
3794
|
+
};
|
3842
3795
|
|
3843
3796
|
/**
|
3844
3797
|
* Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then
|
@@ -3980,115 +3933,41 @@
|
|
3980
3933
|
});
|
3981
3934
|
};
|
3982
3935
|
|
3983
|
-
|
3984
|
-
*
|
3985
|
-
*
|
3986
|
-
* @returns {Observable}
|
3936
|
+
/**
|
3937
|
+
* Executes a transducer to transform the observable sequence
|
3938
|
+
* @param {Transducer} transducer A transducer to execute
|
3939
|
+
* @returns {Observable} An Observable sequence containing the results from the transducer.
|
3987
3940
|
*/
|
3988
|
-
observableProto.
|
3989
|
-
var
|
3990
|
-
return new AnonymousObservable(function (observer) {
|
3991
|
-
var hasCurrent = false,
|
3992
|
-
isStopped = false,
|
3993
|
-
m = new SingleAssignmentDisposable(),
|
3994
|
-
g = new CompositeDisposable();
|
3995
|
-
|
3996
|
-
g.add(m);
|
3997
|
-
|
3998
|
-
m.setDisposable(sources.subscribe(
|
3999
|
-
function (innerSource) {
|
4000
|
-
if (!hasCurrent) {
|
4001
|
-
hasCurrent = true;
|
4002
|
-
|
4003
|
-
isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
|
4004
|
-
|
4005
|
-
var innerSubscription = new SingleAssignmentDisposable();
|
4006
|
-
g.add(innerSubscription);
|
3941
|
+
observableProto.transduce = function(transducer) {
|
3942
|
+
var source = this;
|
4007
3943
|
|
4008
|
-
|
4009
|
-
|
4010
|
-
|
4011
|
-
|
4012
|
-
g.remove(innerSubscription);
|
4013
|
-
hasCurrent = false;
|
4014
|
-
if (isStopped && g.length === 1) {
|
4015
|
-
observer.onCompleted();
|
4016
|
-
}
|
4017
|
-
}));
|
4018
|
-
}
|
3944
|
+
function transformForObserver(observer) {
|
3945
|
+
return {
|
3946
|
+
init: function() {
|
3947
|
+
return observer;
|
4019
3948
|
},
|
4020
|
-
|
4021
|
-
|
4022
|
-
isStopped = true;
|
4023
|
-
if (!hasCurrent && g.length === 1) {
|
4024
|
-
observer.onCompleted();
|
4025
|
-
}
|
4026
|
-
}));
|
4027
|
-
|
4028
|
-
return g;
|
4029
|
-
});
|
4030
|
-
};
|
4031
|
-
|
4032
|
-
/*
|
4033
|
-
* Performs a exclusive map waiting for the first to finish before subscribing to another observable.
|
4034
|
-
* Observables that come in between subscriptions will be dropped on the floor.
|
4035
|
-
* @param {Function} selector Selector to invoke for every item in the current subscription.
|
4036
|
-
* @param {Any} [thisArg] An optional context to invoke with the selector parameter.
|
4037
|
-
* @returns {Observable} An exclusive observable with only the results that happen when subscribed.
|
4038
|
-
*/
|
4039
|
-
observableProto.exclusiveMap = function (selector, thisArg) {
|
4040
|
-
var sources = this;
|
4041
|
-
return new AnonymousObservable(function (observer) {
|
4042
|
-
var index = 0,
|
4043
|
-
hasCurrent = false,
|
4044
|
-
isStopped = true,
|
4045
|
-
m = new SingleAssignmentDisposable(),
|
4046
|
-
g = new CompositeDisposable();
|
4047
|
-
|
4048
|
-
g.add(m);
|
4049
|
-
|
4050
|
-
m.setDisposable(sources.subscribe(
|
4051
|
-
function (innerSource) {
|
4052
|
-
|
4053
|
-
if (!hasCurrent) {
|
4054
|
-
hasCurrent = true;
|
4055
|
-
|
4056
|
-
innerSubscription = new SingleAssignmentDisposable();
|
4057
|
-
g.add(innerSubscription);
|
4058
|
-
|
4059
|
-
isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
|
4060
|
-
|
4061
|
-
innerSubscription.setDisposable(innerSource.subscribe(
|
4062
|
-
function (x) {
|
4063
|
-
var result;
|
4064
|
-
try {
|
4065
|
-
result = selector.call(thisArg, x, index++, innerSource);
|
4066
|
-
} catch (e) {
|
4067
|
-
observer.onError(e);
|
4068
|
-
return;
|
4069
|
-
}
|
4070
|
-
|
4071
|
-
observer.onNext(result);
|
4072
|
-
},
|
4073
|
-
observer.onError.bind(observer),
|
4074
|
-
function () {
|
4075
|
-
g.remove(innerSubscription);
|
4076
|
-
hasCurrent = false;
|
4077
|
-
|
4078
|
-
if (isStopped && g.length === 1) {
|
4079
|
-
observer.onCompleted();
|
4080
|
-
}
|
4081
|
-
}));
|
4082
|
-
}
|
3949
|
+
step: function(obs, input) {
|
3950
|
+
return obs.onNext(input);
|
4083
3951
|
},
|
4084
|
-
|
4085
|
-
|
4086
|
-
|
4087
|
-
|
4088
|
-
|
3952
|
+
result: function(obs) {
|
3953
|
+
return obs.onCompleted();
|
3954
|
+
}
|
3955
|
+
};
|
3956
|
+
}
|
3957
|
+
|
3958
|
+
return new AnonymousObservable(function(observer) {
|
3959
|
+
var xform = transducer(transformForObserver(observer));
|
3960
|
+
return source.subscribe(
|
3961
|
+
function(v) {
|
3962
|
+
try {
|
3963
|
+
xform.step(observer, v);
|
3964
|
+
} catch (e) {
|
3965
|
+
observer.onError(e);
|
4089
3966
|
}
|
4090
|
-
}
|
4091
|
-
|
3967
|
+
},
|
3968
|
+
observer.onError.bind(observer),
|
3969
|
+
function() { xform.result(observer); }
|
3970
|
+
);
|
4092
3971
|
});
|
4093
3972
|
};
|
4094
3973
|
|