rxjs-rails 2.2.19 → 2.2.20
Sign up to get free protection for your applications and to get access to all the features.
- 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
|
|
@@ -1090,25 +1090,25 @@
|
|
1090
1090
|
return SchedulePeriodicRecursive;
|
1091
1091
|
}());
|
1092
1092
|
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1093
|
+
/**
|
1094
|
+
* Gets a scheduler that schedules work immediately on the current thread.
|
1095
|
+
*/
|
1096
|
+
var immediateScheduler = Scheduler.immediate = (function () {
|
1097
1097
|
|
1098
|
-
|
1098
|
+
function scheduleNow(state, action) { return action(this, state); }
|
1099
1099
|
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1100
|
+
function scheduleRelative(state, dueTime, action) {
|
1101
|
+
var dt = normalizeTime(dt);
|
1102
|
+
while (dt - this.now() > 0) { }
|
1103
|
+
return action(this, state);
|
1104
|
+
}
|
1105
1105
|
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1106
|
+
function scheduleAbsolute(state, dueTime, action) {
|
1107
|
+
return this.scheduleWithRelativeAndState(state, dueTime - this.now(), action);
|
1108
|
+
}
|
1109
1109
|
|
1110
|
-
|
1111
|
-
|
1110
|
+
return new Scheduler(defaultNow, scheduleNow, scheduleRelative, scheduleAbsolute);
|
1111
|
+
}());
|
1112
1112
|
|
1113
1113
|
/**
|
1114
1114
|
* Gets a scheduler that schedules work as soon as possible on the current thread.
|
@@ -1172,143 +1172,143 @@
|
|
1172
1172
|
return currentScheduler;
|
1173
1173
|
}());
|
1174
1174
|
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
var reNative = RegExp('^' +
|
1180
|
-
String(toString)
|
1181
|
-
.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
1182
|
-
.replace(/toString| for [^\]]+/g, '.*?') + '$'
|
1183
|
-
);
|
1184
|
-
|
1185
|
-
var setImmediate = typeof (setImmediate = freeGlobal && moduleExports && freeGlobal.setImmediate) == 'function' &&
|
1186
|
-
!reNative.test(setImmediate) && setImmediate,
|
1187
|
-
clearImmediate = typeof (clearImmediate = freeGlobal && moduleExports && freeGlobal.clearImmediate) == 'function' &&
|
1188
|
-
!reNative.test(clearImmediate) && clearImmediate;
|
1189
|
-
|
1190
|
-
function postMessageSupported () {
|
1191
|
-
// Ensure not in a worker
|
1192
|
-
if (!root.postMessage || root.importScripts) { return false; }
|
1193
|
-
var isAsync = false,
|
1194
|
-
oldHandler = root.onmessage;
|
1195
|
-
// Test for async
|
1196
|
-
root.onmessage = function () { isAsync = true; };
|
1197
|
-
root.postMessage('','*');
|
1198
|
-
root.onmessage = oldHandler;
|
1199
|
-
|
1200
|
-
return isAsync;
|
1201
|
-
}
|
1175
|
+
|
1176
|
+
var scheduleMethod, clearMethod = noop;
|
1177
|
+
(function () {
|
1202
1178
|
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1179
|
+
var reNative = RegExp('^' +
|
1180
|
+
String(toString)
|
1181
|
+
.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
1182
|
+
.replace(/toString| for [^\]]+/g, '.*?') + '$'
|
1183
|
+
);
|
1184
|
+
|
1185
|
+
var setImmediate = typeof (setImmediate = freeGlobal && moduleExports && freeGlobal.setImmediate) == 'function' &&
|
1186
|
+
!reNative.test(setImmediate) && setImmediate,
|
1187
|
+
clearImmediate = typeof (clearImmediate = freeGlobal && moduleExports && freeGlobal.clearImmediate) == 'function' &&
|
1188
|
+
!reNative.test(clearImmediate) && clearImmediate;
|
1189
|
+
|
1190
|
+
function postMessageSupported () {
|
1191
|
+
// Ensure not in a worker
|
1192
|
+
if (!root.postMessage || root.importScripts) { return false; }
|
1193
|
+
var isAsync = false,
|
1194
|
+
oldHandler = root.onmessage;
|
1195
|
+
// Test for async
|
1196
|
+
root.onmessage = function () { isAsync = true; };
|
1197
|
+
root.postMessage('','*');
|
1198
|
+
root.onmessage = oldHandler;
|
1199
|
+
|
1200
|
+
return isAsync;
|
1201
|
+
}
|
1223
1202
|
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1203
|
+
// Use in order, nextTick, setImmediate, postMessage, MessageChannel, script readystatechanged, setTimeout
|
1204
|
+
if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') {
|
1205
|
+
scheduleMethod = process.nextTick;
|
1206
|
+
} else if (typeof setImmediate === 'function') {
|
1207
|
+
scheduleMethod = setImmediate;
|
1208
|
+
clearMethod = clearImmediate;
|
1209
|
+
} else if (postMessageSupported()) {
|
1210
|
+
var MSG_PREFIX = 'ms.rx.schedule' + Math.random(),
|
1211
|
+
tasks = {},
|
1212
|
+
taskId = 0;
|
1213
|
+
|
1214
|
+
function onGlobalPostMessage(event) {
|
1215
|
+
// Only if we're a match to avoid any other global events
|
1216
|
+
if (typeof event.data === 'string' && event.data.substring(0, MSG_PREFIX.length) === MSG_PREFIX) {
|
1217
|
+
var handleId = event.data.substring(MSG_PREFIX.length),
|
1218
|
+
action = tasks[handleId];
|
1219
|
+
action();
|
1220
|
+
delete tasks[handleId];
|
1228
1221
|
}
|
1222
|
+
}
|
1229
1223
|
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
} else if (!!root.MessageChannel) {
|
1236
|
-
var channel = new root.MessageChannel(),
|
1237
|
-
channelTasks = {},
|
1238
|
-
channelTaskId = 0;
|
1239
|
-
|
1240
|
-
channel.port1.onmessage = function (event) {
|
1241
|
-
var id = event.data,
|
1242
|
-
action = channelTasks[id];
|
1243
|
-
action();
|
1244
|
-
delete channelTasks[id];
|
1245
|
-
};
|
1224
|
+
if (root.addEventListener) {
|
1225
|
+
root.addEventListener('message', onGlobalPostMessage, false);
|
1226
|
+
} else {
|
1227
|
+
root.attachEvent('onmessage', onGlobalPostMessage, false);
|
1228
|
+
}
|
1246
1229
|
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1230
|
+
scheduleMethod = function (action) {
|
1231
|
+
var currentId = taskId++;
|
1232
|
+
tasks[currentId] = action;
|
1233
|
+
root.postMessage(MSG_PREFIX + currentId, '*');
|
1234
|
+
};
|
1235
|
+
} else if (!!root.MessageChannel) {
|
1236
|
+
var channel = new root.MessageChannel(),
|
1237
|
+
channelTasks = {},
|
1238
|
+
channelTaskId = 0;
|
1239
|
+
|
1240
|
+
channel.port1.onmessage = function (event) {
|
1241
|
+
var id = event.data,
|
1242
|
+
action = channelTasks[id];
|
1243
|
+
action();
|
1244
|
+
delete channelTasks[id];
|
1245
|
+
};
|
1246
|
+
|
1247
|
+
scheduleMethod = function (action) {
|
1248
|
+
var id = channelTaskId++;
|
1249
|
+
channelTasks[id] = action;
|
1250
|
+
channel.port2.postMessage(id);
|
1251
|
+
};
|
1252
|
+
} else if ('document' in root && 'onreadystatechange' in root.document.createElement('script')) {
|
1253
|
+
|
1254
|
+
scheduleMethod = function (action) {
|
1255
|
+
var scriptElement = root.document.createElement('script');
|
1256
|
+
scriptElement.onreadystatechange = function () {
|
1257
|
+
action();
|
1258
|
+
scriptElement.onreadystatechange = null;
|
1259
|
+
scriptElement.parentNode.removeChild(scriptElement);
|
1260
|
+
scriptElement = null;
|
1261
|
+
};
|
1262
|
+
root.document.documentElement.appendChild(scriptElement);
|
1263
|
+
};
|
1270
1264
|
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1265
|
+
} else {
|
1266
|
+
scheduleMethod = function (action) { return setTimeout(action, 0); };
|
1267
|
+
clearMethod = clearTimeout;
|
1268
|
+
}
|
1269
|
+
}());
|
1275
1270
|
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1271
|
+
/**
|
1272
|
+
* Gets a scheduler that schedules work via a timed callback based upon platform.
|
1273
|
+
*/
|
1274
|
+
var timeoutScheduler = Scheduler.timeout = (function () {
|
1275
|
+
|
1276
|
+
function scheduleNow(state, action) {
|
1277
|
+
var scheduler = this,
|
1278
|
+
disposable = new SingleAssignmentDisposable();
|
1279
|
+
var id = scheduleMethod(function () {
|
1280
|
+
if (!disposable.isDisposed) {
|
1281
|
+
disposable.setDisposable(action(scheduler, state));
|
1282
|
+
}
|
1283
|
+
});
|
1284
|
+
return new CompositeDisposable(disposable, disposableCreate(function () {
|
1285
|
+
clearMethod(id);
|
1286
|
+
}));
|
1287
|
+
}
|
1288
1288
|
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
}
|
1295
|
-
var disposable = new SingleAssignmentDisposable();
|
1296
|
-
var id = setTimeout(function () {
|
1297
|
-
if (!disposable.isDisposed) {
|
1298
|
-
disposable.setDisposable(action(scheduler, state));
|
1299
|
-
}
|
1300
|
-
}, dt);
|
1301
|
-
return new CompositeDisposable(disposable, disposableCreate(function () {
|
1302
|
-
clearTimeout(id);
|
1303
|
-
}));
|
1289
|
+
function scheduleRelative(state, dueTime, action) {
|
1290
|
+
var scheduler = this,
|
1291
|
+
dt = Scheduler.normalize(dueTime);
|
1292
|
+
if (dt === 0) {
|
1293
|
+
return scheduler.scheduleWithState(state, action);
|
1304
1294
|
}
|
1295
|
+
var disposable = new SingleAssignmentDisposable();
|
1296
|
+
var id = setTimeout(function () {
|
1297
|
+
if (!disposable.isDisposed) {
|
1298
|
+
disposable.setDisposable(action(scheduler, state));
|
1299
|
+
}
|
1300
|
+
}, dt);
|
1301
|
+
return new CompositeDisposable(disposable, disposableCreate(function () {
|
1302
|
+
clearTimeout(id);
|
1303
|
+
}));
|
1304
|
+
}
|
1305
1305
|
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1306
|
+
function scheduleAbsolute(state, dueTime, action) {
|
1307
|
+
return this.scheduleWithRelativeAndState(state, dueTime - this.now(), action);
|
1308
|
+
}
|
1309
1309
|
|
1310
|
-
|
1311
|
-
|
1310
|
+
return new Scheduler(defaultNow, scheduleNow, scheduleRelative, scheduleAbsolute);
|
1311
|
+
})();
|
1312
1312
|
|
1313
1313
|
/** @private */
|
1314
1314
|
var CatchScheduler = (function (_super) {
|
@@ -2207,28 +2207,26 @@
|
|
2207
2207
|
return new AnonymousObservable(subscribe);
|
2208
2208
|
};
|
2209
2209
|
|
2210
|
-
|
2211
|
-
|
2212
|
-
|
2213
|
-
|
2214
|
-
|
2215
|
-
|
2216
|
-
|
2217
|
-
|
2218
|
-
|
2219
|
-
|
2220
|
-
|
2221
|
-
|
2222
|
-
|
2223
|
-
|
2224
|
-
|
2225
|
-
|
2226
|
-
|
2227
|
-
|
2228
|
-
|
2229
|
-
|
2230
|
-
});
|
2231
|
-
};
|
2210
|
+
/**
|
2211
|
+
* Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes.
|
2212
|
+
*
|
2213
|
+
* @example
|
2214
|
+
* var res = Rx.Observable.defer(function () { return Rx.Observable.fromArray([1,2,3]); });
|
2215
|
+
* @param {Function} observableFactory Observable factory function to invoke for each observer that subscribes to the resulting sequence or Promise.
|
2216
|
+
* @returns {Observable} An observable sequence whose observers trigger an invocation of the given observable factory function.
|
2217
|
+
*/
|
2218
|
+
var observableDefer = Observable.defer = function (observableFactory) {
|
2219
|
+
return new AnonymousObservable(function (observer) {
|
2220
|
+
var result;
|
2221
|
+
try {
|
2222
|
+
result = observableFactory();
|
2223
|
+
} catch (e) {
|
2224
|
+
return observableThrow(e).subscribe(observer);
|
2225
|
+
}
|
2226
|
+
isPromise(result) && (result = observableFromPromise(result));
|
2227
|
+
return result.subscribe(observer);
|
2228
|
+
});
|
2229
|
+
};
|
2232
2230
|
|
2233
2231
|
/**
|
2234
2232
|
* Returns an empty observable sequence, using the specified scheduler to send out the single OnCompleted message.
|
@@ -2476,125 +2474,128 @@
|
|
2476
2474
|
});
|
2477
2475
|
};
|
2478
2476
|
|
2479
|
-
|
2480
|
-
|
2481
|
-
|
2482
|
-
|
2483
|
-
|
2484
|
-
|
2485
|
-
|
2486
|
-
|
2487
|
-
|
2488
|
-
|
2489
|
-
|
2490
|
-
|
2491
|
-
rightSubscription = new SingleAssignmentDisposable();
|
2492
|
-
|
2493
|
-
function choiceL() {
|
2494
|
-
if (!choice) {
|
2495
|
-
choice = leftChoice;
|
2496
|
-
rightSubscription.dispose();
|
2497
|
-
}
|
2498
|
-
}
|
2477
|
+
/**
|
2478
|
+
* Propagates the observable sequence or Promise that reacts first.
|
2479
|
+
* @param {Observable} rightSource Second observable sequence or Promise.
|
2480
|
+
* @returns {Observable} {Observable} An observable sequence that surfaces either of the given sequences, whichever reacted first.
|
2481
|
+
*/
|
2482
|
+
observableProto.amb = function (rightSource) {
|
2483
|
+
var leftSource = this;
|
2484
|
+
return new AnonymousObservable(function (observer) {
|
2485
|
+
var choice,
|
2486
|
+
leftChoice = 'L', rightChoice = 'R',
|
2487
|
+
leftSubscription = new SingleAssignmentDisposable(),
|
2488
|
+
rightSubscription = new SingleAssignmentDisposable();
|
2499
2489
|
|
2500
|
-
|
2501
|
-
if (!choice) {
|
2502
|
-
choice = rightChoice;
|
2503
|
-
leftSubscription.dispose();
|
2504
|
-
}
|
2505
|
-
}
|
2490
|
+
isPromise(rightSource) && (rightSource = observableFromPromise(rightSource));
|
2506
2491
|
|
2507
|
-
|
2508
|
-
|
2509
|
-
|
2510
|
-
|
2511
|
-
|
2512
|
-
|
2513
|
-
choiceL();
|
2514
|
-
if (choice === leftChoice) {
|
2515
|
-
observer.onError(err);
|
2516
|
-
}
|
2517
|
-
}, function () {
|
2518
|
-
choiceL();
|
2519
|
-
if (choice === leftChoice) {
|
2520
|
-
observer.onCompleted();
|
2521
|
-
}
|
2522
|
-
}));
|
2492
|
+
function choiceL() {
|
2493
|
+
if (!choice) {
|
2494
|
+
choice = leftChoice;
|
2495
|
+
rightSubscription.dispose();
|
2496
|
+
}
|
2497
|
+
}
|
2523
2498
|
|
2524
|
-
|
2525
|
-
|
2526
|
-
|
2527
|
-
|
2528
|
-
|
2529
|
-
|
2530
|
-
choiceR();
|
2531
|
-
if (choice === rightChoice) {
|
2532
|
-
observer.onError(err);
|
2533
|
-
}
|
2534
|
-
}, function () {
|
2535
|
-
choiceR();
|
2536
|
-
if (choice === rightChoice) {
|
2537
|
-
observer.onCompleted();
|
2538
|
-
}
|
2539
|
-
}));
|
2499
|
+
function choiceR() {
|
2500
|
+
if (!choice) {
|
2501
|
+
choice = rightChoice;
|
2502
|
+
leftSubscription.dispose();
|
2503
|
+
}
|
2504
|
+
}
|
2540
2505
|
|
2541
|
-
|
2542
|
-
|
2543
|
-
|
2506
|
+
leftSubscription.setDisposable(leftSource.subscribe(function (left) {
|
2507
|
+
choiceL();
|
2508
|
+
if (choice === leftChoice) {
|
2509
|
+
observer.onNext(left);
|
2510
|
+
}
|
2511
|
+
}, function (err) {
|
2512
|
+
choiceL();
|
2513
|
+
if (choice === leftChoice) {
|
2514
|
+
observer.onError(err);
|
2515
|
+
}
|
2516
|
+
}, function () {
|
2517
|
+
choiceL();
|
2518
|
+
if (choice === leftChoice) {
|
2519
|
+
observer.onCompleted();
|
2520
|
+
}
|
2521
|
+
}));
|
2544
2522
|
|
2545
|
-
|
2546
|
-
|
2547
|
-
|
2548
|
-
|
2549
|
-
|
2550
|
-
|
2551
|
-
|
2552
|
-
|
2553
|
-
|
2554
|
-
items = argsOrArray(arguments, 0);
|
2555
|
-
function func(previous, current) {
|
2556
|
-
return previous.amb(current);
|
2523
|
+
rightSubscription.setDisposable(rightSource.subscribe(function (right) {
|
2524
|
+
choiceR();
|
2525
|
+
if (choice === rightChoice) {
|
2526
|
+
observer.onNext(right);
|
2527
|
+
}
|
2528
|
+
}, function (err) {
|
2529
|
+
choiceR();
|
2530
|
+
if (choice === rightChoice) {
|
2531
|
+
observer.onError(err);
|
2557
2532
|
}
|
2558
|
-
|
2559
|
-
|
2533
|
+
}, function () {
|
2534
|
+
choiceR();
|
2535
|
+
if (choice === rightChoice) {
|
2536
|
+
observer.onCompleted();
|
2560
2537
|
}
|
2561
|
-
|
2562
|
-
};
|
2538
|
+
}));
|
2563
2539
|
|
2564
|
-
|
2565
|
-
|
2566
|
-
|
2567
|
-
|
2568
|
-
|
2569
|
-
|
2570
|
-
|
2571
|
-
|
2572
|
-
|
2573
|
-
|
2574
|
-
|
2575
|
-
|
2576
|
-
|
2577
|
-
|
2578
|
-
|
2579
|
-
|
2580
|
-
return subscription;
|
2581
|
-
});
|
2540
|
+
return new CompositeDisposable(leftSubscription, rightSubscription);
|
2541
|
+
});
|
2542
|
+
};
|
2543
|
+
|
2544
|
+
/**
|
2545
|
+
* Propagates the observable sequence or Promise that reacts first.
|
2546
|
+
*
|
2547
|
+
* @example
|
2548
|
+
* var = Rx.Observable.amb(xs, ys, zs);
|
2549
|
+
* @returns {Observable} An observable sequence that surfaces any of the given sequences, whichever reacted first.
|
2550
|
+
*/
|
2551
|
+
Observable.amb = function () {
|
2552
|
+
var acc = observableNever(),
|
2553
|
+
items = argsOrArray(arguments, 0);
|
2554
|
+
function func(previous, current) {
|
2555
|
+
return previous.amb(current);
|
2582
2556
|
}
|
2557
|
+
for (var i = 0, len = items.length; i < len; i++) {
|
2558
|
+
acc = func(acc, items[i]);
|
2559
|
+
}
|
2560
|
+
return acc;
|
2561
|
+
};
|
2583
2562
|
|
2584
|
-
|
2585
|
-
|
2586
|
-
|
2587
|
-
|
2588
|
-
|
2589
|
-
|
2590
|
-
|
2591
|
-
|
2592
|
-
|
2593
|
-
|
2594
|
-
|
2563
|
+
function observableCatchHandler(source, handler) {
|
2564
|
+
return new AnonymousObservable(function (observer) {
|
2565
|
+
var d1 = new SingleAssignmentDisposable(), subscription = new SerialDisposable();
|
2566
|
+
subscription.setDisposable(d1);
|
2567
|
+
d1.setDisposable(source.subscribe(observer.onNext.bind(observer), function (exception) {
|
2568
|
+
var d, result;
|
2569
|
+
try {
|
2570
|
+
result = handler(exception);
|
2571
|
+
} catch (ex) {
|
2572
|
+
observer.onError(ex);
|
2573
|
+
return;
|
2595
2574
|
}
|
2596
|
-
|
2597
|
-
|
2575
|
+
isPromise(result) && (result = observableFromPromise(result));
|
2576
|
+
|
2577
|
+
d = new SingleAssignmentDisposable();
|
2578
|
+
subscription.setDisposable(d);
|
2579
|
+
d.setDisposable(result.subscribe(observer));
|
2580
|
+
}, observer.onCompleted.bind(observer)));
|
2581
|
+
|
2582
|
+
return subscription;
|
2583
|
+
});
|
2584
|
+
}
|
2585
|
+
|
2586
|
+
/**
|
2587
|
+
* Continues an observable sequence that is terminated by an exception with the next observable sequence.
|
2588
|
+
* @example
|
2589
|
+
* 1 - xs.catchException(ys)
|
2590
|
+
* 2 - xs.catchException(function (ex) { return ys(ex); })
|
2591
|
+
* @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.
|
2592
|
+
* @returns {Observable} An observable sequence containing the first sequence's elements, followed by the elements of the handler sequence in case an exception occurred.
|
2593
|
+
*/
|
2594
|
+
observableProto['catch'] = observableProto.catchException = function (handlerOrSecond) {
|
2595
|
+
return typeof handlerOrSecond === 'function' ?
|
2596
|
+
observableCatchHandler(this, handlerOrSecond) :
|
2597
|
+
observableCatch([this, handlerOrSecond]);
|
2598
|
+
};
|
2598
2599
|
|
2599
2600
|
/**
|
2600
2601
|
* Continues an observable sequence that is terminated by an exception with the next observable sequence.
|
@@ -2609,87 +2610,89 @@
|
|
2609
2610
|
return enumerableFor(items).catchException();
|
2610
2611
|
};
|
2611
2612
|
|
2612
|
-
|
2613
|
-
|
2614
|
-
|
2615
|
-
|
2616
|
-
|
2617
|
-
|
2618
|
-
|
2619
|
-
|
2620
|
-
|
2621
|
-
|
2622
|
-
|
2623
|
-
|
2624
|
-
|
2625
|
-
|
2626
|
-
|
2627
|
-
|
2628
|
-
|
2629
|
-
|
2630
|
-
|
2631
|
-
/**
|
2632
|
-
* Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
|
2633
|
-
*
|
2634
|
-
* @example
|
2635
|
-
* 1 - obs = Rx.Observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
|
2636
|
-
* 2 - obs = Rx.Observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
|
2637
|
-
* @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
|
2638
|
-
*/
|
2639
|
-
var combineLatest = Observable.combineLatest = function () {
|
2640
|
-
var args = slice.call(arguments), resultSelector = args.pop();
|
2641
|
-
|
2642
|
-
if (Array.isArray(args[0])) {
|
2643
|
-
args = args[0];
|
2644
|
-
}
|
2613
|
+
/**
|
2614
|
+
* 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.
|
2615
|
+
* This can be in the form of an argument list of observables or an array.
|
2616
|
+
*
|
2617
|
+
* @example
|
2618
|
+
* 1 - obs = observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
|
2619
|
+
* 2 - obs = observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
|
2620
|
+
* @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
|
2621
|
+
*/
|
2622
|
+
observableProto.combineLatest = function () {
|
2623
|
+
var args = slice.call(arguments);
|
2624
|
+
if (Array.isArray(args[0])) {
|
2625
|
+
args[0].unshift(this);
|
2626
|
+
} else {
|
2627
|
+
args.unshift(this);
|
2628
|
+
}
|
2629
|
+
return combineLatest.apply(this, args);
|
2630
|
+
};
|
2645
2631
|
|
2646
|
-
|
2647
|
-
|
2648
|
-
|
2649
|
-
|
2650
|
-
|
2651
|
-
|
2652
|
-
|
2632
|
+
/**
|
2633
|
+
* 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.
|
2634
|
+
*
|
2635
|
+
* @example
|
2636
|
+
* 1 - obs = Rx.Observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
|
2637
|
+
* 2 - obs = Rx.Observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
|
2638
|
+
* @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
|
2639
|
+
*/
|
2640
|
+
var combineLatest = Observable.combineLatest = function () {
|
2641
|
+
var args = slice.call(arguments), resultSelector = args.pop();
|
2642
|
+
|
2643
|
+
if (Array.isArray(args[0])) {
|
2644
|
+
args = args[0];
|
2645
|
+
}
|
2653
2646
|
|
2654
|
-
|
2655
|
-
|
2656
|
-
|
2657
|
-
|
2658
|
-
|
2659
|
-
|
2660
|
-
|
2661
|
-
|
2662
|
-
|
2663
|
-
|
2664
|
-
|
2665
|
-
|
2666
|
-
|
2667
|
-
|
2668
|
-
|
2647
|
+
return new AnonymousObservable(function (observer) {
|
2648
|
+
var falseFactory = function () { return false; },
|
2649
|
+
n = args.length,
|
2650
|
+
hasValue = arrayInitialize(n, falseFactory),
|
2651
|
+
hasValueAll = false,
|
2652
|
+
isDone = arrayInitialize(n, falseFactory),
|
2653
|
+
values = new Array(n);
|
2654
|
+
|
2655
|
+
function next(i) {
|
2656
|
+
var res;
|
2657
|
+
hasValue[i] = true;
|
2658
|
+
if (hasValueAll || (hasValueAll = hasValue.every(identity))) {
|
2659
|
+
try {
|
2660
|
+
res = resultSelector.apply(null, values);
|
2661
|
+
} catch (ex) {
|
2662
|
+
observer.onError(ex);
|
2663
|
+
return;
|
2664
|
+
}
|
2665
|
+
observer.onNext(res);
|
2666
|
+
} else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) {
|
2667
|
+
observer.onCompleted();
|
2668
|
+
}
|
2669
|
+
}
|
2669
2670
|
|
2670
|
-
|
2671
|
-
|
2672
|
-
|
2673
|
-
|
2674
|
-
|
2675
|
-
|
2671
|
+
function done (i) {
|
2672
|
+
isDone[i] = true;
|
2673
|
+
if (isDone.every(identity)) {
|
2674
|
+
observer.onCompleted();
|
2675
|
+
}
|
2676
|
+
}
|
2676
2677
|
|
2677
|
-
|
2678
|
-
|
2679
|
-
|
2680
|
-
|
2681
|
-
|
2682
|
-
|
2683
|
-
|
2684
|
-
|
2685
|
-
|
2686
|
-
|
2687
|
-
|
2688
|
-
|
2678
|
+
var subscriptions = new Array(n);
|
2679
|
+
for (var idx = 0; idx < n; idx++) {
|
2680
|
+
(function (i) {
|
2681
|
+
var source = args[i], sad = new SingleAssignmentDisposable();
|
2682
|
+
isPromise(source) && (source = observableFromPromise(source));
|
2683
|
+
sad.setDisposable(source.subscribe(function (x) {
|
2684
|
+
values[i] = x;
|
2685
|
+
next(i);
|
2686
|
+
}, observer.onError.bind(observer), function () {
|
2687
|
+
done(i);
|
2688
|
+
}));
|
2689
|
+
subscriptions[i] = sad;
|
2690
|
+
}(idx));
|
2691
|
+
}
|
2689
2692
|
|
2690
|
-
|
2691
|
-
|
2692
|
-
|
2693
|
+
return new CompositeDisposable(subscriptions);
|
2694
|
+
});
|
2695
|
+
};
|
2693
2696
|
|
2694
2697
|
/**
|
2695
2698
|
* Concatenates all the observable sequences. This takes in either an array or variable arguments to concatenate.
|
@@ -2848,48 +2851,49 @@
|
|
2848
2851
|
});
|
2849
2852
|
};
|
2850
2853
|
|
2851
|
-
|
2852
|
-
|
2853
|
-
|
2854
|
-
|
2855
|
-
|
2856
|
-
|
2857
|
-
|
2858
|
-
|
2859
|
-
|
2860
|
-
|
2861
|
-
|
2854
|
+
/**
|
2855
|
+
* Continues an observable sequence that is terminated normally or by an exception with the next observable sequence.
|
2856
|
+
* @param {Observable} second Second observable sequence used to produce results after the first sequence terminates.
|
2857
|
+
* @returns {Observable} An observable sequence that concatenates the first and second sequence, even if the first sequence terminates exceptionally.
|
2858
|
+
*/
|
2859
|
+
observableProto.onErrorResumeNext = function (second) {
|
2860
|
+
if (!second) {
|
2861
|
+
throw new Error('Second observable is required');
|
2862
|
+
}
|
2863
|
+
return onErrorResumeNext([this, second]);
|
2864
|
+
};
|
2862
2865
|
|
2863
|
-
|
2864
|
-
|
2865
|
-
|
2866
|
-
|
2867
|
-
|
2868
|
-
|
2869
|
-
|
2870
|
-
|
2871
|
-
|
2872
|
-
|
2873
|
-
|
2874
|
-
|
2875
|
-
|
2876
|
-
|
2877
|
-
|
2878
|
-
|
2879
|
-
|
2880
|
-
|
2881
|
-
|
2882
|
-
|
2883
|
-
|
2884
|
-
|
2885
|
-
|
2886
|
-
|
2887
|
-
|
2888
|
-
|
2889
|
-
|
2890
|
-
|
2891
|
-
|
2892
|
-
};
|
2866
|
+
/**
|
2867
|
+
* Continues an observable sequence that is terminated normally or by an exception with the next observable sequence.
|
2868
|
+
*
|
2869
|
+
* @example
|
2870
|
+
* 1 - res = Rx.Observable.onErrorResumeNext(xs, ys, zs);
|
2871
|
+
* 1 - res = Rx.Observable.onErrorResumeNext([xs, ys, zs]);
|
2872
|
+
* @returns {Observable} An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.
|
2873
|
+
*/
|
2874
|
+
var onErrorResumeNext = Observable.onErrorResumeNext = function () {
|
2875
|
+
var sources = argsOrArray(arguments, 0);
|
2876
|
+
return new AnonymousObservable(function (observer) {
|
2877
|
+
var pos = 0, subscription = new SerialDisposable(),
|
2878
|
+
cancelable = immediateScheduler.scheduleRecursive(function (self) {
|
2879
|
+
var current, d;
|
2880
|
+
if (pos < sources.length) {
|
2881
|
+
current = sources[pos++];
|
2882
|
+
isPromise(current) && (current = observableFromPromise(current));
|
2883
|
+
d = new SingleAssignmentDisposable();
|
2884
|
+
subscription.setDisposable(d);
|
2885
|
+
d.setDisposable(current.subscribe(observer.onNext.bind(observer), function () {
|
2886
|
+
self();
|
2887
|
+
}, function () {
|
2888
|
+
self();
|
2889
|
+
}));
|
2890
|
+
} else {
|
2891
|
+
observer.onCompleted();
|
2892
|
+
}
|
2893
|
+
});
|
2894
|
+
return new CompositeDisposable(subscription, cancelable);
|
2895
|
+
});
|
2896
|
+
};
|
2893
2897
|
|
2894
2898
|
/**
|
2895
2899
|
* Returns the values from the source observable sequence only after the other observable sequence produces a value.
|
@@ -2985,86 +2989,88 @@
|
|
2985
2989
|
});
|
2986
2990
|
};
|
2987
2991
|
|
2988
|
-
|
2989
|
-
|
2990
|
-
|
2991
|
-
|
2992
|
-
|
2993
|
-
|
2994
|
-
|
2995
|
-
|
2996
|
-
|
2997
|
-
|
2998
|
-
|
2999
|
-
|
3000
|
-
|
3001
|
-
|
3002
|
-
|
3003
|
-
|
3004
|
-
|
3005
|
-
|
3006
|
-
|
3007
|
-
|
2992
|
+
function zipArray(second, resultSelector) {
|
2993
|
+
var first = this;
|
2994
|
+
return new AnonymousObservable(function (observer) {
|
2995
|
+
var index = 0, len = second.length;
|
2996
|
+
return first.subscribe(function (left) {
|
2997
|
+
if (index < len) {
|
2998
|
+
var right = second[index++], result;
|
2999
|
+
try {
|
3000
|
+
result = resultSelector(left, right);
|
3001
|
+
} catch (e) {
|
3002
|
+
observer.onError(e);
|
3003
|
+
return;
|
3004
|
+
}
|
3005
|
+
observer.onNext(result);
|
3006
|
+
} else {
|
3007
|
+
observer.onCompleted();
|
3008
|
+
}
|
3009
|
+
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
3010
|
+
});
|
3011
|
+
}
|
3008
3012
|
|
3009
|
-
|
3010
|
-
|
3011
|
-
|
3012
|
-
|
3013
|
-
|
3014
|
-
|
3015
|
-
|
3016
|
-
|
3017
|
-
|
3018
|
-
|
3019
|
-
|
3020
|
-
|
3013
|
+
/**
|
3014
|
+
* 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.
|
3015
|
+
* The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the sources.
|
3016
|
+
*
|
3017
|
+
* @example
|
3018
|
+
* 1 - res = obs1.zip(obs2, fn);
|
3019
|
+
* 1 - res = x1.zip([1,2,3], fn);
|
3020
|
+
* @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
|
3021
|
+
*/
|
3022
|
+
observableProto.zip = function () {
|
3023
|
+
if (Array.isArray(arguments[0])) {
|
3024
|
+
return zipArray.apply(this, arguments);
|
3025
|
+
}
|
3026
|
+
var parent = this, sources = slice.call(arguments), resultSelector = sources.pop();
|
3027
|
+
sources.unshift(parent);
|
3028
|
+
return new AnonymousObservable(function (observer) {
|
3029
|
+
var n = sources.length,
|
3030
|
+
queues = arrayInitialize(n, function () { return []; }),
|
3031
|
+
isDone = arrayInitialize(n, function () { return false; });
|
3032
|
+
|
3033
|
+
function next(i) {
|
3034
|
+
var res, queuedValues;
|
3035
|
+
if (queues.every(function (x) { return x.length > 0; })) {
|
3036
|
+
try {
|
3037
|
+
queuedValues = queues.map(function (x) { return x.shift(); });
|
3038
|
+
res = resultSelector.apply(parent, queuedValues);
|
3039
|
+
} catch (ex) {
|
3040
|
+
observer.onError(ex);
|
3041
|
+
return;
|
3042
|
+
}
|
3043
|
+
observer.onNext(res);
|
3044
|
+
} else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) {
|
3045
|
+
observer.onCompleted();
|
3021
3046
|
}
|
3022
|
-
|
3023
|
-
sources.unshift(parent);
|
3024
|
-
return new AnonymousObservable(function (observer) {
|
3025
|
-
var n = sources.length,
|
3026
|
-
queues = arrayInitialize(n, function () { return []; }),
|
3027
|
-
isDone = arrayInitialize(n, function () { return false; });
|
3028
|
-
|
3029
|
-
var next = function (i) {
|
3030
|
-
var res, queuedValues;
|
3031
|
-
if (queues.every(function (x) { return x.length > 0; })) {
|
3032
|
-
try {
|
3033
|
-
queuedValues = queues.map(function (x) { return x.shift(); });
|
3034
|
-
res = resultSelector.apply(parent, queuedValues);
|
3035
|
-
} catch (ex) {
|
3036
|
-
observer.onError(ex);
|
3037
|
-
return;
|
3038
|
-
}
|
3039
|
-
observer.onNext(res);
|
3040
|
-
} else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) {
|
3041
|
-
observer.onCompleted();
|
3042
|
-
}
|
3043
|
-
};
|
3047
|
+
};
|
3044
3048
|
|
3045
|
-
|
3046
|
-
|
3047
|
-
|
3048
|
-
|
3049
|
-
|
3050
|
-
|
3049
|
+
function done(i) {
|
3050
|
+
isDone[i] = true;
|
3051
|
+
if (isDone.every(function (x) { return x; })) {
|
3052
|
+
observer.onCompleted();
|
3053
|
+
}
|
3054
|
+
}
|
3051
3055
|
|
3052
|
-
|
3053
|
-
|
3054
|
-
|
3055
|
-
|
3056
|
-
|
3057
|
-
|
3058
|
-
|
3059
|
-
|
3060
|
-
|
3061
|
-
|
3062
|
-
|
3063
|
-
|
3056
|
+
var subscriptions = new Array(n);
|
3057
|
+
for (var idx = 0; idx < n; idx++) {
|
3058
|
+
(function (i) {
|
3059
|
+
var source = sources[i], sad = new SingleAssignmentDisposable();
|
3060
|
+
isPromise(source) && (source = observableFromPromise(source));
|
3061
|
+
sad.setDisposable(source.subscribe(function (x) {
|
3062
|
+
queues[i].push(x);
|
3063
|
+
next(i);
|
3064
|
+
}, observer.onError.bind(observer), function () {
|
3065
|
+
done(i);
|
3066
|
+
}));
|
3067
|
+
subscriptions[i] = sad;
|
3068
|
+
})(idx);
|
3069
|
+
}
|
3064
3070
|
|
3065
|
-
|
3066
|
-
|
3067
|
-
|
3071
|
+
return new CompositeDisposable(subscriptions);
|
3072
|
+
});
|
3073
|
+
};
|
3068
3074
|
/**
|
3069
3075
|
* 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.
|
3070
3076
|
* @param arguments Observable sources.
|