rxjs-rails 2.2.19 → 2.2.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +2 -2
- data/lib/rxjs/rails/version.rb +1 -1
- data/vendor/assets/javascripts/rx.aggregates.js +126 -121
- data/vendor/assets/javascripts/rx.aggregates.min.js +1 -1
- data/vendor/assets/javascripts/rx.async.compat.js +2 -1
- data/vendor/assets/javascripts/rx.async.compat.min.js +1 -1
- data/vendor/assets/javascripts/rx.async.js +2 -1
- data/vendor/assets/javascripts/rx.async.min.js +1 -1
- data/vendor/assets/javascripts/rx.compat.js +470 -464
- data/vendor/assets/javascripts/rx.compat.min.js +2 -2
- data/vendor/assets/javascripts/rx.experimental.js +202 -191
- data/vendor/assets/javascripts/rx.experimental.min.js +1 -1
- data/vendor/assets/javascripts/rx.js +470 -464
- data/vendor/assets/javascripts/rx.lite.compat.js +352 -348
- data/vendor/assets/javascripts/rx.lite.compat.min.js +2 -2
- data/vendor/assets/javascripts/rx.lite.js +352 -348
- data/vendor/assets/javascripts/rx.lite.min.js +2 -2
- data/vendor/assets/javascripts/rx.min.js +2 -2
- data/vendor/assets/javascripts/rx.node.js +113 -115
- data/version.rb.m4 +6 -0
- metadata +3 -2
@@ -37,7 +37,7 @@
|
|
37
37
|
defaultSubComparer = Rx.helpers.defaultSubComparer = function (x, y) { return x > y ? 1 : (x < y ? -1 : 0); },
|
38
38
|
defaultKeySerializer = Rx.helpers.defaultKeySerializer = function (x) { return x.toString(); },
|
39
39
|
defaultError = Rx.helpers.defaultError = function (err) { throw err; },
|
40
|
-
isPromise = Rx.helpers.isPromise = function (p) { return typeof p.then === 'function' && p.then !== Rx.Observable.prototype.then; },
|
40
|
+
isPromise = Rx.helpers.isPromise = function (p) { return !!p && typeof p.then === 'function' && p.then !== Rx.Observable.prototype.then; },
|
41
41
|
asArray = Rx.helpers.asArray = function () { return Array.prototype.slice.call(arguments); },
|
42
42
|
not = Rx.helpers.not = function (a) { return !a; };
|
43
43
|
|
@@ -1208,25 +1208,25 @@
|
|
1208
1208
|
return SchedulePeriodicRecursive;
|
1209
1209
|
}());
|
1210
1210
|
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1211
|
+
/**
|
1212
|
+
* Gets a scheduler that schedules work immediately on the current thread.
|
1213
|
+
*/
|
1214
|
+
var immediateScheduler = Scheduler.immediate = (function () {
|
1215
1215
|
|
1216
|
-
|
1216
|
+
function scheduleNow(state, action) { return action(this, state); }
|
1217
1217
|
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1218
|
+
function scheduleRelative(state, dueTime, action) {
|
1219
|
+
var dt = normalizeTime(dt);
|
1220
|
+
while (dt - this.now() > 0) { }
|
1221
|
+
return action(this, state);
|
1222
|
+
}
|
1223
1223
|
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1224
|
+
function scheduleAbsolute(state, dueTime, action) {
|
1225
|
+
return this.scheduleWithRelativeAndState(state, dueTime - this.now(), action);
|
1226
|
+
}
|
1227
1227
|
|
1228
|
-
|
1229
|
-
|
1228
|
+
return new Scheduler(defaultNow, scheduleNow, scheduleRelative, scheduleAbsolute);
|
1229
|
+
}());
|
1230
1230
|
|
1231
1231
|
/**
|
1232
1232
|
* Gets a scheduler that schedules work as soon as possible on the current thread.
|
@@ -1290,143 +1290,143 @@
|
|
1290
1290
|
return currentScheduler;
|
1291
1291
|
}());
|
1292
1292
|
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
var reNative = RegExp('^' +
|
1298
|
-
String(toString)
|
1299
|
-
.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
1300
|
-
.replace(/toString| for [^\]]+/g, '.*?') + '$'
|
1301
|
-
);
|
1302
|
-
|
1303
|
-
var setImmediate = typeof (setImmediate = freeGlobal && moduleExports && freeGlobal.setImmediate) == 'function' &&
|
1304
|
-
!reNative.test(setImmediate) && setImmediate,
|
1305
|
-
clearImmediate = typeof (clearImmediate = freeGlobal && moduleExports && freeGlobal.clearImmediate) == 'function' &&
|
1306
|
-
!reNative.test(clearImmediate) && clearImmediate;
|
1307
|
-
|
1308
|
-
function postMessageSupported () {
|
1309
|
-
// Ensure not in a worker
|
1310
|
-
if (!root.postMessage || root.importScripts) { return false; }
|
1311
|
-
var isAsync = false,
|
1312
|
-
oldHandler = root.onmessage;
|
1313
|
-
// Test for async
|
1314
|
-
root.onmessage = function () { isAsync = true; };
|
1315
|
-
root.postMessage('','*');
|
1316
|
-
root.onmessage = oldHandler;
|
1317
|
-
|
1318
|
-
return isAsync;
|
1319
|
-
}
|
1293
|
+
|
1294
|
+
var scheduleMethod, clearMethod = noop;
|
1295
|
+
(function () {
|
1320
1296
|
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1297
|
+
var reNative = RegExp('^' +
|
1298
|
+
String(toString)
|
1299
|
+
.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
1300
|
+
.replace(/toString| for [^\]]+/g, '.*?') + '$'
|
1301
|
+
);
|
1302
|
+
|
1303
|
+
var setImmediate = typeof (setImmediate = freeGlobal && moduleExports && freeGlobal.setImmediate) == 'function' &&
|
1304
|
+
!reNative.test(setImmediate) && setImmediate,
|
1305
|
+
clearImmediate = typeof (clearImmediate = freeGlobal && moduleExports && freeGlobal.clearImmediate) == 'function' &&
|
1306
|
+
!reNative.test(clearImmediate) && clearImmediate;
|
1307
|
+
|
1308
|
+
function postMessageSupported () {
|
1309
|
+
// Ensure not in a worker
|
1310
|
+
if (!root.postMessage || root.importScripts) { return false; }
|
1311
|
+
var isAsync = false,
|
1312
|
+
oldHandler = root.onmessage;
|
1313
|
+
// Test for async
|
1314
|
+
root.onmessage = function () { isAsync = true; };
|
1315
|
+
root.postMessage('','*');
|
1316
|
+
root.onmessage = oldHandler;
|
1317
|
+
|
1318
|
+
return isAsync;
|
1319
|
+
}
|
1341
1320
|
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1321
|
+
// Use in order, nextTick, setImmediate, postMessage, MessageChannel, script readystatechanged, setTimeout
|
1322
|
+
if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') {
|
1323
|
+
scheduleMethod = process.nextTick;
|
1324
|
+
} else if (typeof setImmediate === 'function') {
|
1325
|
+
scheduleMethod = setImmediate;
|
1326
|
+
clearMethod = clearImmediate;
|
1327
|
+
} else if (postMessageSupported()) {
|
1328
|
+
var MSG_PREFIX = 'ms.rx.schedule' + Math.random(),
|
1329
|
+
tasks = {},
|
1330
|
+
taskId = 0;
|
1331
|
+
|
1332
|
+
function onGlobalPostMessage(event) {
|
1333
|
+
// Only if we're a match to avoid any other global events
|
1334
|
+
if (typeof event.data === 'string' && event.data.substring(0, MSG_PREFIX.length) === MSG_PREFIX) {
|
1335
|
+
var handleId = event.data.substring(MSG_PREFIX.length),
|
1336
|
+
action = tasks[handleId];
|
1337
|
+
action();
|
1338
|
+
delete tasks[handleId];
|
1346
1339
|
}
|
1340
|
+
}
|
1347
1341
|
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
} else if (!!root.MessageChannel) {
|
1354
|
-
var channel = new root.MessageChannel(),
|
1355
|
-
channelTasks = {},
|
1356
|
-
channelTaskId = 0;
|
1357
|
-
|
1358
|
-
channel.port1.onmessage = function (event) {
|
1359
|
-
var id = event.data,
|
1360
|
-
action = channelTasks[id];
|
1361
|
-
action();
|
1362
|
-
delete channelTasks[id];
|
1363
|
-
};
|
1342
|
+
if (root.addEventListener) {
|
1343
|
+
root.addEventListener('message', onGlobalPostMessage, false);
|
1344
|
+
} else {
|
1345
|
+
root.attachEvent('onmessage', onGlobalPostMessage, false);
|
1346
|
+
}
|
1364
1347
|
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1348
|
+
scheduleMethod = function (action) {
|
1349
|
+
var currentId = taskId++;
|
1350
|
+
tasks[currentId] = action;
|
1351
|
+
root.postMessage(MSG_PREFIX + currentId, '*');
|
1352
|
+
};
|
1353
|
+
} else if (!!root.MessageChannel) {
|
1354
|
+
var channel = new root.MessageChannel(),
|
1355
|
+
channelTasks = {},
|
1356
|
+
channelTaskId = 0;
|
1357
|
+
|
1358
|
+
channel.port1.onmessage = function (event) {
|
1359
|
+
var id = event.data,
|
1360
|
+
action = channelTasks[id];
|
1361
|
+
action();
|
1362
|
+
delete channelTasks[id];
|
1363
|
+
};
|
1364
|
+
|
1365
|
+
scheduleMethod = function (action) {
|
1366
|
+
var id = channelTaskId++;
|
1367
|
+
channelTasks[id] = action;
|
1368
|
+
channel.port2.postMessage(id);
|
1369
|
+
};
|
1370
|
+
} else if ('document' in root && 'onreadystatechange' in root.document.createElement('script')) {
|
1371
|
+
|
1372
|
+
scheduleMethod = function (action) {
|
1373
|
+
var scriptElement = root.document.createElement('script');
|
1374
|
+
scriptElement.onreadystatechange = function () {
|
1375
|
+
action();
|
1376
|
+
scriptElement.onreadystatechange = null;
|
1377
|
+
scriptElement.parentNode.removeChild(scriptElement);
|
1378
|
+
scriptElement = null;
|
1379
|
+
};
|
1380
|
+
root.document.documentElement.appendChild(scriptElement);
|
1381
|
+
};
|
1388
1382
|
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1383
|
+
} else {
|
1384
|
+
scheduleMethod = function (action) { return setTimeout(action, 0); };
|
1385
|
+
clearMethod = clearTimeout;
|
1386
|
+
}
|
1387
|
+
}());
|
1393
1388
|
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1389
|
+
/**
|
1390
|
+
* Gets a scheduler that schedules work via a timed callback based upon platform.
|
1391
|
+
*/
|
1392
|
+
var timeoutScheduler = Scheduler.timeout = (function () {
|
1393
|
+
|
1394
|
+
function scheduleNow(state, action) {
|
1395
|
+
var scheduler = this,
|
1396
|
+
disposable = new SingleAssignmentDisposable();
|
1397
|
+
var id = scheduleMethod(function () {
|
1398
|
+
if (!disposable.isDisposed) {
|
1399
|
+
disposable.setDisposable(action(scheduler, state));
|
1400
|
+
}
|
1401
|
+
});
|
1402
|
+
return new CompositeDisposable(disposable, disposableCreate(function () {
|
1403
|
+
clearMethod(id);
|
1404
|
+
}));
|
1405
|
+
}
|
1406
1406
|
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1412
|
-
}
|
1413
|
-
var disposable = new SingleAssignmentDisposable();
|
1414
|
-
var id = setTimeout(function () {
|
1415
|
-
if (!disposable.isDisposed) {
|
1416
|
-
disposable.setDisposable(action(scheduler, state));
|
1417
|
-
}
|
1418
|
-
}, dt);
|
1419
|
-
return new CompositeDisposable(disposable, disposableCreate(function () {
|
1420
|
-
clearTimeout(id);
|
1421
|
-
}));
|
1407
|
+
function scheduleRelative(state, dueTime, action) {
|
1408
|
+
var scheduler = this,
|
1409
|
+
dt = Scheduler.normalize(dueTime);
|
1410
|
+
if (dt === 0) {
|
1411
|
+
return scheduler.scheduleWithState(state, action);
|
1422
1412
|
}
|
1413
|
+
var disposable = new SingleAssignmentDisposable();
|
1414
|
+
var id = setTimeout(function () {
|
1415
|
+
if (!disposable.isDisposed) {
|
1416
|
+
disposable.setDisposable(action(scheduler, state));
|
1417
|
+
}
|
1418
|
+
}, dt);
|
1419
|
+
return new CompositeDisposable(disposable, disposableCreate(function () {
|
1420
|
+
clearTimeout(id);
|
1421
|
+
}));
|
1422
|
+
}
|
1423
1423
|
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1424
|
+
function scheduleAbsolute(state, dueTime, action) {
|
1425
|
+
return this.scheduleWithRelativeAndState(state, dueTime - this.now(), action);
|
1426
|
+
}
|
1427
1427
|
|
1428
|
-
|
1429
|
-
|
1428
|
+
return new Scheduler(defaultNow, scheduleNow, scheduleRelative, scheduleAbsolute);
|
1429
|
+
})();
|
1430
1430
|
|
1431
1431
|
/** @private */
|
1432
1432
|
var CatchScheduler = (function (_super) {
|
@@ -2325,28 +2325,26 @@
|
|
2325
2325
|
return new AnonymousObservable(subscribe);
|
2326
2326
|
};
|
2327
2327
|
|
2328
|
-
|
2329
|
-
|
2330
|
-
|
2331
|
-
|
2332
|
-
|
2333
|
-
|
2334
|
-
|
2335
|
-
|
2336
|
-
|
2337
|
-
|
2338
|
-
|
2339
|
-
|
2340
|
-
|
2341
|
-
|
2342
|
-
|
2343
|
-
|
2344
|
-
|
2345
|
-
|
2346
|
-
|
2347
|
-
|
2348
|
-
});
|
2349
|
-
};
|
2328
|
+
/**
|
2329
|
+
* Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes.
|
2330
|
+
*
|
2331
|
+
* @example
|
2332
|
+
* var res = Rx.Observable.defer(function () { return Rx.Observable.fromArray([1,2,3]); });
|
2333
|
+
* @param {Function} observableFactory Observable factory function to invoke for each observer that subscribes to the resulting sequence or Promise.
|
2334
|
+
* @returns {Observable} An observable sequence whose observers trigger an invocation of the given observable factory function.
|
2335
|
+
*/
|
2336
|
+
var observableDefer = Observable.defer = function (observableFactory) {
|
2337
|
+
return new AnonymousObservable(function (observer) {
|
2338
|
+
var result;
|
2339
|
+
try {
|
2340
|
+
result = observableFactory();
|
2341
|
+
} catch (e) {
|
2342
|
+
return observableThrow(e).subscribe(observer);
|
2343
|
+
}
|
2344
|
+
isPromise(result) && (result = observableFromPromise(result));
|
2345
|
+
return result.subscribe(observer);
|
2346
|
+
});
|
2347
|
+
};
|
2350
2348
|
|
2351
2349
|
/**
|
2352
2350
|
* Returns an empty observable sequence, using the specified scheduler to send out the single OnCompleted message.
|
@@ -2594,125 +2592,128 @@
|
|
2594
2592
|
});
|
2595
2593
|
};
|
2596
2594
|
|
2597
|
-
|
2598
|
-
|
2599
|
-
|
2600
|
-
|
2601
|
-
|
2602
|
-
|
2603
|
-
|
2604
|
-
|
2605
|
-
|
2606
|
-
|
2607
|
-
|
2608
|
-
|
2609
|
-
rightSubscription = new SingleAssignmentDisposable();
|
2610
|
-
|
2611
|
-
function choiceL() {
|
2612
|
-
if (!choice) {
|
2613
|
-
choice = leftChoice;
|
2614
|
-
rightSubscription.dispose();
|
2615
|
-
}
|
2616
|
-
}
|
2595
|
+
/**
|
2596
|
+
* Propagates the observable sequence or Promise that reacts first.
|
2597
|
+
* @param {Observable} rightSource Second observable sequence or Promise.
|
2598
|
+
* @returns {Observable} {Observable} An observable sequence that surfaces either of the given sequences, whichever reacted first.
|
2599
|
+
*/
|
2600
|
+
observableProto.amb = function (rightSource) {
|
2601
|
+
var leftSource = this;
|
2602
|
+
return new AnonymousObservable(function (observer) {
|
2603
|
+
var choice,
|
2604
|
+
leftChoice = 'L', rightChoice = 'R',
|
2605
|
+
leftSubscription = new SingleAssignmentDisposable(),
|
2606
|
+
rightSubscription = new SingleAssignmentDisposable();
|
2617
2607
|
|
2618
|
-
|
2619
|
-
if (!choice) {
|
2620
|
-
choice = rightChoice;
|
2621
|
-
leftSubscription.dispose();
|
2622
|
-
}
|
2623
|
-
}
|
2608
|
+
isPromise(rightSource) && (rightSource = observableFromPromise(rightSource));
|
2624
2609
|
|
2625
|
-
|
2626
|
-
|
2627
|
-
|
2628
|
-
|
2629
|
-
|
2630
|
-
|
2631
|
-
choiceL();
|
2632
|
-
if (choice === leftChoice) {
|
2633
|
-
observer.onError(err);
|
2634
|
-
}
|
2635
|
-
}, function () {
|
2636
|
-
choiceL();
|
2637
|
-
if (choice === leftChoice) {
|
2638
|
-
observer.onCompleted();
|
2639
|
-
}
|
2640
|
-
}));
|
2610
|
+
function choiceL() {
|
2611
|
+
if (!choice) {
|
2612
|
+
choice = leftChoice;
|
2613
|
+
rightSubscription.dispose();
|
2614
|
+
}
|
2615
|
+
}
|
2641
2616
|
|
2642
|
-
|
2643
|
-
|
2644
|
-
|
2645
|
-
|
2646
|
-
|
2647
|
-
|
2648
|
-
choiceR();
|
2649
|
-
if (choice === rightChoice) {
|
2650
|
-
observer.onError(err);
|
2651
|
-
}
|
2652
|
-
}, function () {
|
2653
|
-
choiceR();
|
2654
|
-
if (choice === rightChoice) {
|
2655
|
-
observer.onCompleted();
|
2656
|
-
}
|
2657
|
-
}));
|
2617
|
+
function choiceR() {
|
2618
|
+
if (!choice) {
|
2619
|
+
choice = rightChoice;
|
2620
|
+
leftSubscription.dispose();
|
2621
|
+
}
|
2622
|
+
}
|
2658
2623
|
|
2659
|
-
|
2660
|
-
|
2661
|
-
|
2624
|
+
leftSubscription.setDisposable(leftSource.subscribe(function (left) {
|
2625
|
+
choiceL();
|
2626
|
+
if (choice === leftChoice) {
|
2627
|
+
observer.onNext(left);
|
2628
|
+
}
|
2629
|
+
}, function (err) {
|
2630
|
+
choiceL();
|
2631
|
+
if (choice === leftChoice) {
|
2632
|
+
observer.onError(err);
|
2633
|
+
}
|
2634
|
+
}, function () {
|
2635
|
+
choiceL();
|
2636
|
+
if (choice === leftChoice) {
|
2637
|
+
observer.onCompleted();
|
2638
|
+
}
|
2639
|
+
}));
|
2662
2640
|
|
2663
|
-
|
2664
|
-
|
2665
|
-
|
2666
|
-
|
2667
|
-
|
2668
|
-
|
2669
|
-
|
2670
|
-
|
2671
|
-
|
2672
|
-
items = argsOrArray(arguments, 0);
|
2673
|
-
function func(previous, current) {
|
2674
|
-
return previous.amb(current);
|
2641
|
+
rightSubscription.setDisposable(rightSource.subscribe(function (right) {
|
2642
|
+
choiceR();
|
2643
|
+
if (choice === rightChoice) {
|
2644
|
+
observer.onNext(right);
|
2645
|
+
}
|
2646
|
+
}, function (err) {
|
2647
|
+
choiceR();
|
2648
|
+
if (choice === rightChoice) {
|
2649
|
+
observer.onError(err);
|
2675
2650
|
}
|
2676
|
-
|
2677
|
-
|
2651
|
+
}, function () {
|
2652
|
+
choiceR();
|
2653
|
+
if (choice === rightChoice) {
|
2654
|
+
observer.onCompleted();
|
2678
2655
|
}
|
2679
|
-
|
2680
|
-
};
|
2656
|
+
}));
|
2681
2657
|
|
2682
|
-
|
2683
|
-
|
2684
|
-
|
2685
|
-
|
2686
|
-
|
2687
|
-
|
2688
|
-
|
2689
|
-
|
2690
|
-
|
2691
|
-
|
2692
|
-
|
2693
|
-
|
2694
|
-
|
2695
|
-
|
2696
|
-
|
2697
|
-
|
2698
|
-
return subscription;
|
2699
|
-
});
|
2658
|
+
return new CompositeDisposable(leftSubscription, rightSubscription);
|
2659
|
+
});
|
2660
|
+
};
|
2661
|
+
|
2662
|
+
/**
|
2663
|
+
* Propagates the observable sequence or Promise that reacts first.
|
2664
|
+
*
|
2665
|
+
* @example
|
2666
|
+
* var = Rx.Observable.amb(xs, ys, zs);
|
2667
|
+
* @returns {Observable} An observable sequence that surfaces any of the given sequences, whichever reacted first.
|
2668
|
+
*/
|
2669
|
+
Observable.amb = function () {
|
2670
|
+
var acc = observableNever(),
|
2671
|
+
items = argsOrArray(arguments, 0);
|
2672
|
+
function func(previous, current) {
|
2673
|
+
return previous.amb(current);
|
2700
2674
|
}
|
2675
|
+
for (var i = 0, len = items.length; i < len; i++) {
|
2676
|
+
acc = func(acc, items[i]);
|
2677
|
+
}
|
2678
|
+
return acc;
|
2679
|
+
};
|
2701
2680
|
|
2702
|
-
|
2703
|
-
|
2704
|
-
|
2705
|
-
|
2706
|
-
|
2707
|
-
|
2708
|
-
|
2709
|
-
|
2710
|
-
|
2711
|
-
|
2712
|
-
|
2681
|
+
function observableCatchHandler(source, handler) {
|
2682
|
+
return new AnonymousObservable(function (observer) {
|
2683
|
+
var d1 = new SingleAssignmentDisposable(), subscription = new SerialDisposable();
|
2684
|
+
subscription.setDisposable(d1);
|
2685
|
+
d1.setDisposable(source.subscribe(observer.onNext.bind(observer), function (exception) {
|
2686
|
+
var d, result;
|
2687
|
+
try {
|
2688
|
+
result = handler(exception);
|
2689
|
+
} catch (ex) {
|
2690
|
+
observer.onError(ex);
|
2691
|
+
return;
|
2713
2692
|
}
|
2714
|
-
|
2715
|
-
|
2693
|
+
isPromise(result) && (result = observableFromPromise(result));
|
2694
|
+
|
2695
|
+
d = new SingleAssignmentDisposable();
|
2696
|
+
subscription.setDisposable(d);
|
2697
|
+
d.setDisposable(result.subscribe(observer));
|
2698
|
+
}, observer.onCompleted.bind(observer)));
|
2699
|
+
|
2700
|
+
return subscription;
|
2701
|
+
});
|
2702
|
+
}
|
2703
|
+
|
2704
|
+
/**
|
2705
|
+
* Continues an observable sequence that is terminated by an exception with the next observable sequence.
|
2706
|
+
* @example
|
2707
|
+
* 1 - xs.catchException(ys)
|
2708
|
+
* 2 - xs.catchException(function (ex) { return ys(ex); })
|
2709
|
+
* @param {Mixed} handlerOrSecond Exception handler function that returns an observable sequence given the error that occurred in the first sequence, or a second observable sequence used to produce results when an error occurred in the first sequence.
|
2710
|
+
* @returns {Observable} An observable sequence containing the first sequence's elements, followed by the elements of the handler sequence in case an exception occurred.
|
2711
|
+
*/
|
2712
|
+
observableProto['catch'] = observableProto.catchException = function (handlerOrSecond) {
|
2713
|
+
return typeof handlerOrSecond === 'function' ?
|
2714
|
+
observableCatchHandler(this, handlerOrSecond) :
|
2715
|
+
observableCatch([this, handlerOrSecond]);
|
2716
|
+
};
|
2716
2717
|
|
2717
2718
|
/**
|
2718
2719
|
* Continues an observable sequence that is terminated by an exception with the next observable sequence.
|
@@ -2727,87 +2728,89 @@
|
|
2727
2728
|
return enumerableFor(items).catchException();
|
2728
2729
|
};
|
2729
2730
|
|
2730
|
-
|
2731
|
-
|
2732
|
-
|
2733
|
-
|
2734
|
-
|
2735
|
-
|
2736
|
-
|
2737
|
-
|
2738
|
-
|
2739
|
-
|
2740
|
-
|
2741
|
-
|
2742
|
-
|
2743
|
-
|
2744
|
-
|
2745
|
-
|
2746
|
-
|
2747
|
-
|
2748
|
-
|
2749
|
-
/**
|
2750
|
-
* Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
|
2751
|
-
*
|
2752
|
-
* @example
|
2753
|
-
* 1 - obs = Rx.Observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
|
2754
|
-
* 2 - obs = Rx.Observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
|
2755
|
-
* @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
|
2756
|
-
*/
|
2757
|
-
var combineLatest = Observable.combineLatest = function () {
|
2758
|
-
var args = slice.call(arguments), resultSelector = args.pop();
|
2759
|
-
|
2760
|
-
if (Array.isArray(args[0])) {
|
2761
|
-
args = args[0];
|
2762
|
-
}
|
2731
|
+
/**
|
2732
|
+
* Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.
|
2733
|
+
* This can be in the form of an argument list of observables or an array.
|
2734
|
+
*
|
2735
|
+
* @example
|
2736
|
+
* 1 - obs = observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
|
2737
|
+
* 2 - obs = observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
|
2738
|
+
* @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
|
2739
|
+
*/
|
2740
|
+
observableProto.combineLatest = function () {
|
2741
|
+
var args = slice.call(arguments);
|
2742
|
+
if (Array.isArray(args[0])) {
|
2743
|
+
args[0].unshift(this);
|
2744
|
+
} else {
|
2745
|
+
args.unshift(this);
|
2746
|
+
}
|
2747
|
+
return combineLatest.apply(this, args);
|
2748
|
+
};
|
2763
2749
|
|
2764
|
-
|
2765
|
-
|
2766
|
-
|
2767
|
-
|
2768
|
-
|
2769
|
-
|
2770
|
-
|
2750
|
+
/**
|
2751
|
+
* Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.
|
2752
|
+
*
|
2753
|
+
* @example
|
2754
|
+
* 1 - obs = Rx.Observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
|
2755
|
+
* 2 - obs = Rx.Observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
|
2756
|
+
* @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
|
2757
|
+
*/
|
2758
|
+
var combineLatest = Observable.combineLatest = function () {
|
2759
|
+
var args = slice.call(arguments), resultSelector = args.pop();
|
2760
|
+
|
2761
|
+
if (Array.isArray(args[0])) {
|
2762
|
+
args = args[0];
|
2763
|
+
}
|
2771
2764
|
|
2772
|
-
|
2773
|
-
|
2774
|
-
|
2775
|
-
|
2776
|
-
|
2777
|
-
|
2778
|
-
|
2779
|
-
|
2780
|
-
|
2781
|
-
|
2782
|
-
|
2783
|
-
|
2784
|
-
|
2785
|
-
|
2786
|
-
|
2765
|
+
return new AnonymousObservable(function (observer) {
|
2766
|
+
var falseFactory = function () { return false; },
|
2767
|
+
n = args.length,
|
2768
|
+
hasValue = arrayInitialize(n, falseFactory),
|
2769
|
+
hasValueAll = false,
|
2770
|
+
isDone = arrayInitialize(n, falseFactory),
|
2771
|
+
values = new Array(n);
|
2772
|
+
|
2773
|
+
function next(i) {
|
2774
|
+
var res;
|
2775
|
+
hasValue[i] = true;
|
2776
|
+
if (hasValueAll || (hasValueAll = hasValue.every(identity))) {
|
2777
|
+
try {
|
2778
|
+
res = resultSelector.apply(null, values);
|
2779
|
+
} catch (ex) {
|
2780
|
+
observer.onError(ex);
|
2781
|
+
return;
|
2782
|
+
}
|
2783
|
+
observer.onNext(res);
|
2784
|
+
} else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) {
|
2785
|
+
observer.onCompleted();
|
2786
|
+
}
|
2787
|
+
}
|
2787
2788
|
|
2788
|
-
|
2789
|
-
|
2790
|
-
|
2791
|
-
|
2792
|
-
|
2793
|
-
|
2789
|
+
function done (i) {
|
2790
|
+
isDone[i] = true;
|
2791
|
+
if (isDone.every(identity)) {
|
2792
|
+
observer.onCompleted();
|
2793
|
+
}
|
2794
|
+
}
|
2794
2795
|
|
2795
|
-
|
2796
|
-
|
2797
|
-
|
2798
|
-
|
2799
|
-
|
2800
|
-
|
2801
|
-
|
2802
|
-
|
2803
|
-
|
2804
|
-
|
2805
|
-
|
2806
|
-
|
2796
|
+
var subscriptions = new Array(n);
|
2797
|
+
for (var idx = 0; idx < n; idx++) {
|
2798
|
+
(function (i) {
|
2799
|
+
var source = args[i], sad = new SingleAssignmentDisposable();
|
2800
|
+
isPromise(source) && (source = observableFromPromise(source));
|
2801
|
+
sad.setDisposable(source.subscribe(function (x) {
|
2802
|
+
values[i] = x;
|
2803
|
+
next(i);
|
2804
|
+
}, observer.onError.bind(observer), function () {
|
2805
|
+
done(i);
|
2806
|
+
}));
|
2807
|
+
subscriptions[i] = sad;
|
2808
|
+
}(idx));
|
2809
|
+
}
|
2807
2810
|
|
2808
|
-
|
2809
|
-
|
2810
|
-
|
2811
|
+
return new CompositeDisposable(subscriptions);
|
2812
|
+
});
|
2813
|
+
};
|
2811
2814
|
|
2812
2815
|
/**
|
2813
2816
|
* Concatenates all the observable sequences. This takes in either an array or variable arguments to concatenate.
|
@@ -2966,48 +2969,49 @@
|
|
2966
2969
|
});
|
2967
2970
|
};
|
2968
2971
|
|
2969
|
-
|
2970
|
-
|
2971
|
-
|
2972
|
-
|
2973
|
-
|
2974
|
-
|
2975
|
-
|
2976
|
-
|
2977
|
-
|
2978
|
-
|
2979
|
-
|
2972
|
+
/**
|
2973
|
+
* Continues an observable sequence that is terminated normally or by an exception with the next observable sequence.
|
2974
|
+
* @param {Observable} second Second observable sequence used to produce results after the first sequence terminates.
|
2975
|
+
* @returns {Observable} An observable sequence that concatenates the first and second sequence, even if the first sequence terminates exceptionally.
|
2976
|
+
*/
|
2977
|
+
observableProto.onErrorResumeNext = function (second) {
|
2978
|
+
if (!second) {
|
2979
|
+
throw new Error('Second observable is required');
|
2980
|
+
}
|
2981
|
+
return onErrorResumeNext([this, second]);
|
2982
|
+
};
|
2980
2983
|
|
2981
|
-
|
2982
|
-
|
2983
|
-
|
2984
|
-
|
2985
|
-
|
2986
|
-
|
2987
|
-
|
2988
|
-
|
2989
|
-
|
2990
|
-
|
2991
|
-
|
2992
|
-
|
2993
|
-
|
2994
|
-
|
2995
|
-
|
2996
|
-
|
2997
|
-
|
2998
|
-
|
2999
|
-
|
3000
|
-
|
3001
|
-
|
3002
|
-
|
3003
|
-
|
3004
|
-
|
3005
|
-
|
3006
|
-
|
3007
|
-
|
3008
|
-
|
3009
|
-
|
3010
|
-
};
|
2984
|
+
/**
|
2985
|
+
* Continues an observable sequence that is terminated normally or by an exception with the next observable sequence.
|
2986
|
+
*
|
2987
|
+
* @example
|
2988
|
+
* 1 - res = Rx.Observable.onErrorResumeNext(xs, ys, zs);
|
2989
|
+
* 1 - res = Rx.Observable.onErrorResumeNext([xs, ys, zs]);
|
2990
|
+
* @returns {Observable} An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.
|
2991
|
+
*/
|
2992
|
+
var onErrorResumeNext = Observable.onErrorResumeNext = function () {
|
2993
|
+
var sources = argsOrArray(arguments, 0);
|
2994
|
+
return new AnonymousObservable(function (observer) {
|
2995
|
+
var pos = 0, subscription = new SerialDisposable(),
|
2996
|
+
cancelable = immediateScheduler.scheduleRecursive(function (self) {
|
2997
|
+
var current, d;
|
2998
|
+
if (pos < sources.length) {
|
2999
|
+
current = sources[pos++];
|
3000
|
+
isPromise(current) && (current = observableFromPromise(current));
|
3001
|
+
d = new SingleAssignmentDisposable();
|
3002
|
+
subscription.setDisposable(d);
|
3003
|
+
d.setDisposable(current.subscribe(observer.onNext.bind(observer), function () {
|
3004
|
+
self();
|
3005
|
+
}, function () {
|
3006
|
+
self();
|
3007
|
+
}));
|
3008
|
+
} else {
|
3009
|
+
observer.onCompleted();
|
3010
|
+
}
|
3011
|
+
});
|
3012
|
+
return new CompositeDisposable(subscription, cancelable);
|
3013
|
+
});
|
3014
|
+
};
|
3011
3015
|
|
3012
3016
|
/**
|
3013
3017
|
* Returns the values from the source observable sequence only after the other observable sequence produces a value.
|
@@ -3103,86 +3107,88 @@
|
|
3103
3107
|
});
|
3104
3108
|
};
|
3105
3109
|
|
3106
|
-
|
3107
|
-
|
3108
|
-
|
3109
|
-
|
3110
|
-
|
3111
|
-
|
3112
|
-
|
3113
|
-
|
3114
|
-
|
3115
|
-
|
3116
|
-
|
3117
|
-
|
3118
|
-
|
3119
|
-
|
3120
|
-
|
3121
|
-
|
3122
|
-
|
3123
|
-
|
3124
|
-
|
3125
|
-
|
3110
|
+
function zipArray(second, resultSelector) {
|
3111
|
+
var first = this;
|
3112
|
+
return new AnonymousObservable(function (observer) {
|
3113
|
+
var index = 0, len = second.length;
|
3114
|
+
return first.subscribe(function (left) {
|
3115
|
+
if (index < len) {
|
3116
|
+
var right = second[index++], result;
|
3117
|
+
try {
|
3118
|
+
result = resultSelector(left, right);
|
3119
|
+
} catch (e) {
|
3120
|
+
observer.onError(e);
|
3121
|
+
return;
|
3122
|
+
}
|
3123
|
+
observer.onNext(result);
|
3124
|
+
} else {
|
3125
|
+
observer.onCompleted();
|
3126
|
+
}
|
3127
|
+
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
3128
|
+
});
|
3129
|
+
}
|
3126
3130
|
|
3127
|
-
|
3128
|
-
|
3129
|
-
|
3130
|
-
|
3131
|
-
|
3132
|
-
|
3133
|
-
|
3134
|
-
|
3135
|
-
|
3136
|
-
|
3137
|
-
|
3138
|
-
|
3131
|
+
/**
|
3132
|
+
* Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index.
|
3133
|
+
* The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the sources.
|
3134
|
+
*
|
3135
|
+
* @example
|
3136
|
+
* 1 - res = obs1.zip(obs2, fn);
|
3137
|
+
* 1 - res = x1.zip([1,2,3], fn);
|
3138
|
+
* @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
|
3139
|
+
*/
|
3140
|
+
observableProto.zip = function () {
|
3141
|
+
if (Array.isArray(arguments[0])) {
|
3142
|
+
return zipArray.apply(this, arguments);
|
3143
|
+
}
|
3144
|
+
var parent = this, sources = slice.call(arguments), resultSelector = sources.pop();
|
3145
|
+
sources.unshift(parent);
|
3146
|
+
return new AnonymousObservable(function (observer) {
|
3147
|
+
var n = sources.length,
|
3148
|
+
queues = arrayInitialize(n, function () { return []; }),
|
3149
|
+
isDone = arrayInitialize(n, function () { return false; });
|
3150
|
+
|
3151
|
+
function next(i) {
|
3152
|
+
var res, queuedValues;
|
3153
|
+
if (queues.every(function (x) { return x.length > 0; })) {
|
3154
|
+
try {
|
3155
|
+
queuedValues = queues.map(function (x) { return x.shift(); });
|
3156
|
+
res = resultSelector.apply(parent, queuedValues);
|
3157
|
+
} catch (ex) {
|
3158
|
+
observer.onError(ex);
|
3159
|
+
return;
|
3160
|
+
}
|
3161
|
+
observer.onNext(res);
|
3162
|
+
} else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) {
|
3163
|
+
observer.onCompleted();
|
3139
3164
|
}
|
3140
|
-
|
3141
|
-
sources.unshift(parent);
|
3142
|
-
return new AnonymousObservable(function (observer) {
|
3143
|
-
var n = sources.length,
|
3144
|
-
queues = arrayInitialize(n, function () { return []; }),
|
3145
|
-
isDone = arrayInitialize(n, function () { return false; });
|
3146
|
-
|
3147
|
-
var next = function (i) {
|
3148
|
-
var res, queuedValues;
|
3149
|
-
if (queues.every(function (x) { return x.length > 0; })) {
|
3150
|
-
try {
|
3151
|
-
queuedValues = queues.map(function (x) { return x.shift(); });
|
3152
|
-
res = resultSelector.apply(parent, queuedValues);
|
3153
|
-
} catch (ex) {
|
3154
|
-
observer.onError(ex);
|
3155
|
-
return;
|
3156
|
-
}
|
3157
|
-
observer.onNext(res);
|
3158
|
-
} else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) {
|
3159
|
-
observer.onCompleted();
|
3160
|
-
}
|
3161
|
-
};
|
3165
|
+
};
|
3162
3166
|
|
3163
|
-
|
3164
|
-
|
3165
|
-
|
3166
|
-
|
3167
|
-
|
3168
|
-
|
3167
|
+
function done(i) {
|
3168
|
+
isDone[i] = true;
|
3169
|
+
if (isDone.every(function (x) { return x; })) {
|
3170
|
+
observer.onCompleted();
|
3171
|
+
}
|
3172
|
+
}
|
3169
3173
|
|
3170
|
-
|
3171
|
-
|
3172
|
-
|
3173
|
-
|
3174
|
-
|
3175
|
-
|
3176
|
-
|
3177
|
-
|
3178
|
-
|
3179
|
-
|
3180
|
-
|
3181
|
-
|
3174
|
+
var subscriptions = new Array(n);
|
3175
|
+
for (var idx = 0; idx < n; idx++) {
|
3176
|
+
(function (i) {
|
3177
|
+
var source = sources[i], sad = new SingleAssignmentDisposable();
|
3178
|
+
isPromise(source) && (source = observableFromPromise(source));
|
3179
|
+
sad.setDisposable(source.subscribe(function (x) {
|
3180
|
+
queues[i].push(x);
|
3181
|
+
next(i);
|
3182
|
+
}, observer.onError.bind(observer), function () {
|
3183
|
+
done(i);
|
3184
|
+
}));
|
3185
|
+
subscriptions[i] = sad;
|
3186
|
+
})(idx);
|
3187
|
+
}
|
3182
3188
|
|
3183
|
-
|
3184
|
-
|
3185
|
-
|
3189
|
+
return new CompositeDisposable(subscriptions);
|
3190
|
+
});
|
3191
|
+
};
|
3186
3192
|
/**
|
3187
3193
|
* Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
|
3188
3194
|
* @param arguments Observable sources.
|