rxjs-rails 2.3.9 → 2.3.10
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 +174 -204
- data/vendor/assets/javascripts/rx.aggregates.min.js +1 -1
- data/vendor/assets/javascripts/rx.all.compat.js +1626 -1528
- data/vendor/assets/javascripts/rx.all.compat.min.js +3 -3
- data/vendor/assets/javascripts/rx.all.js +1624 -1526
- data/vendor/assets/javascripts/rx.all.min.js +3 -3
- data/vendor/assets/javascripts/rx.async.compat.js +241 -0
- data/vendor/assets/javascripts/rx.async.compat.min.js +1 -1
- data/vendor/assets/javascripts/rx.async.js +241 -0
- data/vendor/assets/javascripts/rx.async.min.js +1 -1
- data/vendor/assets/javascripts/rx.backpressure.js +3 -3
- data/vendor/assets/javascripts/rx.backpressure.min.js +1 -1
- data/vendor/assets/javascripts/rx.binding.js +350 -378
- data/vendor/assets/javascripts/rx.binding.min.js +1 -1
- data/vendor/assets/javascripts/rx.coincidence.js +16 -21
- data/vendor/assets/javascripts/rx.compat.js +633 -683
- data/vendor/assets/javascripts/rx.compat.min.js +2 -2
- data/vendor/assets/javascripts/rx.js +633 -683
- data/vendor/assets/javascripts/rx.lite.compat.js +941 -1137
- data/vendor/assets/javascripts/rx.lite.compat.min.js +2 -2
- data/vendor/assets/javascripts/rx.lite.extras.js +58 -74
- data/vendor/assets/javascripts/rx.lite.extras.min.js +1 -1
- data/vendor/assets/javascripts/rx.lite.js +941 -1137
- data/vendor/assets/javascripts/rx.lite.min.js +2 -2
- data/vendor/assets/javascripts/rx.min.js +2 -2
- data/vendor/assets/javascripts/rx.time.js +182 -212
- data/vendor/assets/javascripts/rx.time.min.js +1 -1
- metadata +10 -10
@@ -43,7 +43,22 @@
|
|
43
43
|
defaultError = Rx.helpers.defaultError = function (err) { throw err; },
|
44
44
|
isPromise = Rx.helpers.isPromise = function (p) { return !!p && typeof p.then === 'function'; },
|
45
45
|
asArray = Rx.helpers.asArray = function () { return Array.prototype.slice.call(arguments); },
|
46
|
-
not = Rx.helpers.not = function (a) { return !a; }
|
46
|
+
not = Rx.helpers.not = function (a) { return !a; },
|
47
|
+
isFunction = Rx.helpers.isFunction = (function () {
|
48
|
+
|
49
|
+
var isFn = function (value) {
|
50
|
+
return typeof value == 'function' || false;
|
51
|
+
}
|
52
|
+
|
53
|
+
// fallback for older versions of Chrome and Safari
|
54
|
+
if (isFn(/x/)) {
|
55
|
+
isFn = function(value) {
|
56
|
+
return typeof value == 'function' && toString.call(value) == '[object Function]';
|
57
|
+
};
|
58
|
+
}
|
59
|
+
|
60
|
+
return isFn;
|
61
|
+
}());
|
47
62
|
|
48
63
|
// Errors
|
49
64
|
var sequenceContainsNoElements = 'Sequence contains no elements.';
|
@@ -198,18 +213,7 @@
|
|
198
213
|
isArguments = function(value) {
|
199
214
|
return (value && typeof value == 'object') ? hasOwnProperty.call(value, 'callee') : false;
|
200
215
|
};
|
201
|
-
}
|
202
|
-
|
203
|
-
function isFunction(value) {
|
204
|
-
return typeof value == 'function' || false;
|
205
|
-
}
|
206
|
-
|
207
|
-
// fallback for older versions of Chrome and Safari
|
208
|
-
if (isFunction(/x/)) {
|
209
|
-
isFunction = function(value) {
|
210
|
-
return typeof value == 'function' && toString.call(value) == funcClass;
|
211
|
-
};
|
212
|
-
}
|
216
|
+
}
|
213
217
|
|
214
218
|
var isEqual = Rx.internals.isEqual = function (x, y) {
|
215
219
|
return deepEquals(x, y, [], []);
|
@@ -395,101 +399,91 @@
|
|
395
399
|
return a;
|
396
400
|
}
|
397
401
|
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
402
|
+
// Collections
|
403
|
+
function IndexedItem(id, value) {
|
404
|
+
this.id = id;
|
405
|
+
this.value = value;
|
406
|
+
}
|
403
407
|
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
return c;
|
410
|
-
};
|
408
|
+
IndexedItem.prototype.compareTo = function (other) {
|
409
|
+
var c = this.value.compareTo(other.value);
|
410
|
+
c === 0 && (c = this.id - other.id);
|
411
|
+
return c;
|
412
|
+
};
|
411
413
|
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
414
|
+
// Priority Queue for Scheduling
|
415
|
+
var PriorityQueue = Rx.internals.PriorityQueue = function (capacity) {
|
416
|
+
this.items = new Array(capacity);
|
417
|
+
this.length = 0;
|
418
|
+
};
|
417
419
|
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
420
|
+
var priorityProto = PriorityQueue.prototype;
|
421
|
+
priorityProto.isHigherPriority = function (left, right) {
|
422
|
+
return this.items[left].compareTo(this.items[right]) < 0;
|
423
|
+
};
|
422
424
|
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
this.items[parent] = temp;
|
435
|
-
this.percolate(parent);
|
436
|
-
}
|
437
|
-
};
|
425
|
+
priorityProto.percolate = function (index) {
|
426
|
+
if (index >= this.length || index < 0) { return; }
|
427
|
+
var parent = index - 1 >> 1;
|
428
|
+
if (parent < 0 || parent === index) { return; }
|
429
|
+
if (this.isHigherPriority(index, parent)) {
|
430
|
+
var temp = this.items[index];
|
431
|
+
this.items[index] = this.items[parent];
|
432
|
+
this.items[parent] = temp;
|
433
|
+
this.percolate(parent);
|
434
|
+
}
|
435
|
+
};
|
438
436
|
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
}
|
461
|
-
};
|
462
|
-
|
463
|
-
priorityProto.peek = function () { return this.items[0].value; };
|
437
|
+
priorityProto.heapify = function (index) {
|
438
|
+
+index || (index = 0);
|
439
|
+
if (index >= this.length || index < 0) { return; }
|
440
|
+
var left = 2 * index + 1,
|
441
|
+
right = 2 * index + 2,
|
442
|
+
first = index;
|
443
|
+
if (left < this.length && this.isHigherPriority(left, first)) {
|
444
|
+
first = left;
|
445
|
+
}
|
446
|
+
if (right < this.length && this.isHigherPriority(right, first)) {
|
447
|
+
first = right;
|
448
|
+
}
|
449
|
+
if (first !== index) {
|
450
|
+
var temp = this.items[index];
|
451
|
+
this.items[index] = this.items[first];
|
452
|
+
this.items[first] = temp;
|
453
|
+
this.heapify(first);
|
454
|
+
}
|
455
|
+
};
|
456
|
+
|
457
|
+
priorityProto.peek = function () { return this.items[0].value; };
|
464
458
|
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
459
|
+
priorityProto.removeAt = function (index) {
|
460
|
+
this.items[index] = this.items[--this.length];
|
461
|
+
delete this.items[this.length];
|
462
|
+
this.heapify();
|
463
|
+
};
|
470
464
|
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
465
|
+
priorityProto.dequeue = function () {
|
466
|
+
var result = this.peek();
|
467
|
+
this.removeAt(0);
|
468
|
+
return result;
|
469
|
+
};
|
476
470
|
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
471
|
+
priorityProto.enqueue = function (item) {
|
472
|
+
var index = this.length++;
|
473
|
+
this.items[index] = new IndexedItem(PriorityQueue.count++, item);
|
474
|
+
this.percolate(index);
|
475
|
+
};
|
482
476
|
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
477
|
+
priorityProto.remove = function (item) {
|
478
|
+
for (var i = 0; i < this.length; i++) {
|
479
|
+
if (this.items[i].value === item) {
|
480
|
+
this.removeAt(i);
|
481
|
+
return true;
|
482
|
+
}
|
483
|
+
}
|
484
|
+
return false;
|
485
|
+
};
|
486
|
+
PriorityQueue.count = 0;
|
493
487
|
/**
|
494
488
|
* Represents a group of disposable resources that are disposed together.
|
495
489
|
* @constructor
|
@@ -558,39 +552,38 @@
|
|
558
552
|
return this.disposables.slice(0);
|
559
553
|
};
|
560
554
|
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
555
|
+
/**
|
556
|
+
* Provides a set of static methods for creating Disposables.
|
557
|
+
*
|
558
|
+
* @constructor
|
559
|
+
* @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once.
|
560
|
+
*/
|
561
|
+
var Disposable = Rx.Disposable = function (action) {
|
562
|
+
this.isDisposed = false;
|
563
|
+
this.action = action || noop;
|
564
|
+
};
|
571
565
|
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
566
|
+
/** Performs the task of cleaning up resources. */
|
567
|
+
Disposable.prototype.dispose = function () {
|
568
|
+
if (!this.isDisposed) {
|
569
|
+
this.action();
|
570
|
+
this.isDisposed = true;
|
571
|
+
}
|
572
|
+
};
|
579
573
|
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
574
|
+
/**
|
575
|
+
* Creates a disposable object that invokes the specified action when disposed.
|
576
|
+
* @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once.
|
577
|
+
* @return {Disposable} The disposable object that runs the given action upon disposal.
|
578
|
+
*/
|
579
|
+
var disposableCreate = Disposable.create = function (action) { return new Disposable(action); };
|
586
580
|
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
581
|
+
/**
|
582
|
+
* Gets the disposable that does nothing when disposed.
|
583
|
+
*/
|
584
|
+
var disposableEmpty = Disposable.empty = { dispose: noop };
|
591
585
|
|
592
|
-
var SingleAssignmentDisposable = Rx.SingleAssignmentDisposable =
|
593
|
-
SerialDisposable = Rx.SerialDisposable = (function () {
|
586
|
+
var SingleAssignmentDisposable = Rx.SingleAssignmentDisposable = (function () {
|
594
587
|
function BooleanDisposable () {
|
595
588
|
this.isDisposed = false;
|
596
589
|
this.current = null;
|
@@ -635,6 +628,7 @@
|
|
635
628
|
|
636
629
|
return BooleanDisposable;
|
637
630
|
}());
|
631
|
+
var SerialDisposable = Rx.SerialDisposable = SingleAssignmentDisposable;
|
638
632
|
/**
|
639
633
|
* Represents a disposable resource that only disposes its underlying disposable resource when all dependent disposable objects have been disposed.
|
640
634
|
*/
|
@@ -1003,6 +997,7 @@
|
|
1003
997
|
}(Scheduler.prototype));
|
1004
998
|
|
1005
999
|
(function (schedulerProto) {
|
1000
|
+
|
1006
1001
|
/**
|
1007
1002
|
* Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be scheduled using window.setInterval for the base implementation.
|
1008
1003
|
* @param {Number} period Period for running the work periodically.
|
@@ -1020,17 +1015,19 @@
|
|
1020
1015
|
* @param {Function} action Action to be executed, potentially updating the state.
|
1021
1016
|
* @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort).
|
1022
1017
|
*/
|
1023
|
-
Scheduler.prototype.schedulePeriodicWithState = function
|
1018
|
+
Scheduler.prototype.schedulePeriodicWithState = function(state, period, action) {
|
1019
|
+
if (typeof root.setInterval === 'undefined') { throw new Error('Periodic scheduling not supported.'); }
|
1024
1020
|
var s = state;
|
1025
|
-
|
1026
|
-
var id = setInterval(function () {
|
1021
|
+
|
1022
|
+
var id = root.setInterval(function () {
|
1027
1023
|
s = action(s);
|
1028
1024
|
}, period);
|
1029
1025
|
|
1030
1026
|
return disposableCreate(function () {
|
1031
|
-
clearInterval(id);
|
1027
|
+
root.clearInterval(id);
|
1032
1028
|
});
|
1033
1029
|
};
|
1030
|
+
|
1034
1031
|
}(Scheduler.prototype));
|
1035
1032
|
|
1036
1033
|
(function (schedulerProto) {
|
@@ -1152,100 +1149,121 @@
|
|
1152
1149
|
return currentScheduler;
|
1153
1150
|
}());
|
1154
1151
|
|
1155
|
-
|
1156
1152
|
var scheduleMethod, clearMethod = noop;
|
1157
|
-
(function () {
|
1153
|
+
var localTimer = (function () {
|
1154
|
+
var localSetTimeout, localClearTimeout = noop;
|
1155
|
+
if ('WScript' in this) {
|
1156
|
+
localSetTimeout = function (fn, time) {
|
1157
|
+
WScript.Sleep(time);
|
1158
|
+
fn();
|
1159
|
+
};
|
1160
|
+
} else if (!!root.setTimeout) {
|
1161
|
+
localSetTimeout = root.setTimeout;
|
1162
|
+
localClearTimeout = root.clearTimeout;
|
1163
|
+
} else {
|
1164
|
+
throw new Error('No concurrency detected!');
|
1165
|
+
}
|
1158
1166
|
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1167
|
+
return {
|
1168
|
+
setTimeout: localSetTimeout,
|
1169
|
+
clearTimeout: localClearTimeout
|
1170
|
+
};
|
1171
|
+
}());
|
1172
|
+
var localSetTimeout = localTimer.setTimeout,
|
1173
|
+
localClearTimeout = localTimer.clearTimeout;
|
1174
|
+
|
1175
|
+
(function () {
|
1176
|
+
|
1177
|
+
var reNative = RegExp('^' +
|
1178
|
+
String(toString)
|
1179
|
+
.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
1180
|
+
.replace(/toString| for [^\]]+/g, '.*?') + '$'
|
1181
|
+
);
|
1182
|
+
|
1183
|
+
var setImmediate = typeof (setImmediate = freeGlobal && moduleExports && freeGlobal.setImmediate) == 'function' &&
|
1184
|
+
!reNative.test(setImmediate) && setImmediate,
|
1185
|
+
clearImmediate = typeof (clearImmediate = freeGlobal && moduleExports && freeGlobal.clearImmediate) == 'function' &&
|
1186
|
+
!reNative.test(clearImmediate) && clearImmediate;
|
1187
|
+
|
1188
|
+
function postMessageSupported () {
|
1189
|
+
// Ensure not in a worker
|
1190
|
+
if (!root.postMessage || root.importScripts) { return false; }
|
1191
|
+
var isAsync = false,
|
1192
|
+
oldHandler = root.onmessage;
|
1193
|
+
// Test for async
|
1194
|
+
root.onmessage = function () { isAsync = true; };
|
1195
|
+
root.postMessage('','*');
|
1196
|
+
root.onmessage = oldHandler;
|
1197
|
+
|
1198
|
+
return isAsync;
|
1199
|
+
}
|
1164
1200
|
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1201
|
+
// Use in order, nextTick, setImmediate, postMessage, MessageChannel, script readystatechanged, setTimeout
|
1202
|
+
if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') {
|
1203
|
+
scheduleMethod = process.nextTick;
|
1204
|
+
} else if (typeof setImmediate === 'function') {
|
1205
|
+
scheduleMethod = setImmediate;
|
1206
|
+
clearMethod = clearImmediate;
|
1207
|
+
} else if (postMessageSupported()) {
|
1208
|
+
var MSG_PREFIX = 'ms.rx.schedule' + Math.random(),
|
1209
|
+
tasks = {},
|
1210
|
+
taskId = 0;
|
1211
|
+
|
1212
|
+
function onGlobalPostMessage(event) {
|
1213
|
+
// Only if we're a match to avoid any other global events
|
1214
|
+
if (typeof event.data === 'string' && event.data.substring(0, MSG_PREFIX.length) === MSG_PREFIX) {
|
1215
|
+
var handleId = event.data.substring(MSG_PREFIX.length),
|
1216
|
+
action = tasks[handleId];
|
1217
|
+
action();
|
1218
|
+
delete tasks[handleId];
|
1219
|
+
}
|
1181
1220
|
}
|
1182
1221
|
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
clearMethod = clearImmediate;
|
1189
|
-
} else if (postMessageSupported()) {
|
1190
|
-
var MSG_PREFIX = 'ms.rx.schedule' + Math.random(),
|
1191
|
-
tasks = {},
|
1192
|
-
taskId = 0;
|
1193
|
-
|
1194
|
-
function onGlobalPostMessage(event) {
|
1195
|
-
// Only if we're a match to avoid any other global events
|
1196
|
-
if (typeof event.data === 'string' && event.data.substring(0, MSG_PREFIX.length) === MSG_PREFIX) {
|
1197
|
-
var handleId = event.data.substring(MSG_PREFIX.length),
|
1198
|
-
action = tasks[handleId];
|
1199
|
-
action();
|
1200
|
-
delete tasks[handleId];
|
1201
|
-
}
|
1202
|
-
}
|
1222
|
+
if (root.addEventListener) {
|
1223
|
+
root.addEventListener('message', onGlobalPostMessage, false);
|
1224
|
+
} else {
|
1225
|
+
root.attachEvent('onmessage', onGlobalPostMessage, false);
|
1226
|
+
}
|
1203
1227
|
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1228
|
+
scheduleMethod = function (action) {
|
1229
|
+
var currentId = taskId++;
|
1230
|
+
tasks[currentId] = action;
|
1231
|
+
root.postMessage(MSG_PREFIX + currentId, '*');
|
1232
|
+
};
|
1233
|
+
} else if (!!root.MessageChannel) {
|
1234
|
+
var channel = new root.MessageChannel(),
|
1235
|
+
channelTasks = {},
|
1236
|
+
channelTaskId = 0;
|
1237
|
+
|
1238
|
+
channel.port1.onmessage = function (event) {
|
1239
|
+
var id = event.data,
|
1240
|
+
action = channelTasks[id];
|
1241
|
+
action();
|
1242
|
+
delete channelTasks[id];
|
1243
|
+
};
|
1209
1244
|
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
delete channelTasks[id];
|
1225
|
-
};
|
1226
|
-
|
1227
|
-
scheduleMethod = function (action) {
|
1228
|
-
var id = channelTaskId++;
|
1229
|
-
channelTasks[id] = action;
|
1230
|
-
channel.port2.postMessage(id);
|
1231
|
-
};
|
1232
|
-
} else if ('document' in root && 'onreadystatechange' in root.document.createElement('script')) {
|
1233
|
-
|
1234
|
-
scheduleMethod = function (action) {
|
1235
|
-
var scriptElement = root.document.createElement('script');
|
1236
|
-
scriptElement.onreadystatechange = function () {
|
1237
|
-
action();
|
1238
|
-
scriptElement.onreadystatechange = null;
|
1239
|
-
scriptElement.parentNode.removeChild(scriptElement);
|
1240
|
-
scriptElement = null;
|
1241
|
-
};
|
1242
|
-
root.document.documentElement.appendChild(scriptElement);
|
1245
|
+
scheduleMethod = function (action) {
|
1246
|
+
var id = channelTaskId++;
|
1247
|
+
channelTasks[id] = action;
|
1248
|
+
channel.port2.postMessage(id);
|
1249
|
+
};
|
1250
|
+
} else if ('document' in root && 'onreadystatechange' in root.document.createElement('script')) {
|
1251
|
+
|
1252
|
+
scheduleMethod = function (action) {
|
1253
|
+
var scriptElement = root.document.createElement('script');
|
1254
|
+
scriptElement.onreadystatechange = function () {
|
1255
|
+
action();
|
1256
|
+
scriptElement.onreadystatechange = null;
|
1257
|
+
scriptElement.parentNode.removeChild(scriptElement);
|
1258
|
+
scriptElement = null;
|
1243
1259
|
};
|
1260
|
+
root.document.documentElement.appendChild(scriptElement);
|
1261
|
+
};
|
1244
1262
|
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1263
|
+
} else {
|
1264
|
+
scheduleMethod = function (action) { return localSetTimeout(action, 0); };
|
1265
|
+
clearMethod = localClearTimeout;
|
1266
|
+
}
|
1249
1267
|
}());
|
1250
1268
|
|
1251
1269
|
/**
|
@@ -1254,33 +1272,33 @@
|
|
1254
1272
|
var timeoutScheduler = Scheduler.timeout = (function () {
|
1255
1273
|
|
1256
1274
|
function scheduleNow(state, action) {
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1275
|
+
var scheduler = this,
|
1276
|
+
disposable = new SingleAssignmentDisposable();
|
1277
|
+
var id = scheduleMethod(function () {
|
1278
|
+
if (!disposable.isDisposed) {
|
1279
|
+
disposable.setDisposable(action(scheduler, state));
|
1280
|
+
}
|
1281
|
+
});
|
1282
|
+
return new CompositeDisposable(disposable, disposableCreate(function () {
|
1283
|
+
clearMethod(id);
|
1284
|
+
}));
|
1267
1285
|
}
|
1268
1286
|
|
1269
1287
|
function scheduleRelative(state, dueTime, action) {
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1288
|
+
var scheduler = this,
|
1289
|
+
dt = Scheduler.normalize(dueTime);
|
1290
|
+
if (dt === 0) {
|
1291
|
+
return scheduler.scheduleWithState(state, action);
|
1292
|
+
}
|
1293
|
+
var disposable = new SingleAssignmentDisposable();
|
1294
|
+
var id = localSetTimeout(function () {
|
1295
|
+
if (!disposable.isDisposed) {
|
1296
|
+
disposable.setDisposable(action(scheduler, state));
|
1274
1297
|
}
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
}
|
1280
|
-
}, dt);
|
1281
|
-
return new CompositeDisposable(disposable, disposableCreate(function () {
|
1282
|
-
clearTimeout(id);
|
1283
|
-
}));
|
1298
|
+
}, dt);
|
1299
|
+
return new CompositeDisposable(disposable, disposableCreate(function () {
|
1300
|
+
localClearTimeout(id);
|
1301
|
+
}));
|
1284
1302
|
}
|
1285
1303
|
|
1286
1304
|
function scheduleAbsolute(state, dueTime, action) {
|
@@ -1872,11 +1890,11 @@
|
|
1872
1890
|
return CheckedObserver;
|
1873
1891
|
}(Observer));
|
1874
1892
|
|
1875
|
-
var ScheduledObserver = Rx.internals.ScheduledObserver = (function (
|
1876
|
-
inherits(ScheduledObserver,
|
1893
|
+
var ScheduledObserver = Rx.internals.ScheduledObserver = (function (__super__) {
|
1894
|
+
inherits(ScheduledObserver, __super__);
|
1877
1895
|
|
1878
1896
|
function ScheduledObserver(scheduler, observer) {
|
1879
|
-
|
1897
|
+
__super__.call(this);
|
1880
1898
|
this.scheduler = scheduler;
|
1881
1899
|
this.observer = observer;
|
1882
1900
|
this.isAcquired = false;
|
@@ -1892,10 +1910,10 @@
|
|
1892
1910
|
});
|
1893
1911
|
};
|
1894
1912
|
|
1895
|
-
ScheduledObserver.prototype.error = function (
|
1913
|
+
ScheduledObserver.prototype.error = function (err) {
|
1896
1914
|
var self = this;
|
1897
1915
|
this.queue.push(function () {
|
1898
|
-
self.observer.onError(
|
1916
|
+
self.observer.onError(err);
|
1899
1917
|
});
|
1900
1918
|
};
|
1901
1919
|
|
@@ -1934,42 +1952,37 @@
|
|
1934
1952
|
};
|
1935
1953
|
|
1936
1954
|
ScheduledObserver.prototype.dispose = function () {
|
1937
|
-
|
1955
|
+
__super__.prototype.dispose.call(this);
|
1938
1956
|
this.disposable.dispose();
|
1939
1957
|
};
|
1940
1958
|
|
1941
1959
|
return ScheduledObserver;
|
1942
1960
|
}(AbstractObserver));
|
1943
1961
|
|
1944
|
-
|
1945
|
-
|
1946
|
-
inherits(ObserveOnObserver, _super);
|
1962
|
+
var ObserveOnObserver = (function (__super__) {
|
1963
|
+
inherits(ObserveOnObserver, __super__);
|
1947
1964
|
|
1948
|
-
|
1949
|
-
|
1950
|
-
|
1951
|
-
}
|
1965
|
+
function ObserveOnObserver() {
|
1966
|
+
__super__.apply(this, arguments);
|
1967
|
+
}
|
1952
1968
|
|
1953
|
-
|
1954
|
-
|
1955
|
-
|
1956
|
-
|
1957
|
-
};
|
1969
|
+
ObserveOnObserver.prototype.next = function (value) {
|
1970
|
+
__super__.prototype.next.call(this, value);
|
1971
|
+
this.ensureActive();
|
1972
|
+
};
|
1958
1973
|
|
1959
|
-
|
1960
|
-
|
1961
|
-
|
1962
|
-
|
1963
|
-
};
|
1974
|
+
ObserveOnObserver.prototype.error = function (e) {
|
1975
|
+
__super__.prototype.error.call(this, e);
|
1976
|
+
this.ensureActive();
|
1977
|
+
};
|
1964
1978
|
|
1965
|
-
|
1966
|
-
|
1967
|
-
|
1968
|
-
|
1969
|
-
};
|
1979
|
+
ObserveOnObserver.prototype.completed = function () {
|
1980
|
+
__super__.prototype.completed.call(this);
|
1981
|
+
this.ensureActive();
|
1982
|
+
};
|
1970
1983
|
|
1971
|
-
|
1972
|
-
|
1984
|
+
return ObserveOnObserver;
|
1985
|
+
})(ScheduledObserver);
|
1973
1986
|
|
1974
1987
|
var observableProto;
|
1975
1988
|
|
@@ -2009,43 +2022,43 @@
|
|
2009
2022
|
return Observable;
|
2010
2023
|
})();
|
2011
2024
|
|
2012
|
-
|
2013
|
-
|
2014
|
-
|
2015
|
-
|
2016
|
-
|
2017
|
-
|
2018
|
-
|
2019
|
-
|
2020
|
-
|
2021
|
-
|
2022
|
-
|
2023
|
-
|
2024
|
-
|
2025
|
-
|
2026
|
-
|
2025
|
+
/**
|
2026
|
+
* Wraps the source sequence in order to run its observer callbacks on the specified scheduler.
|
2027
|
+
*
|
2028
|
+
* This only invokes observer callbacks on a scheduler. In case the subscription and/or unsubscription actions have side-effects
|
2029
|
+
* that require to be run on a scheduler, use subscribeOn.
|
2030
|
+
*
|
2031
|
+
* @param {Scheduler} scheduler Scheduler to notify observers on.
|
2032
|
+
* @returns {Observable} The source sequence whose observations happen on the specified scheduler.
|
2033
|
+
*/
|
2034
|
+
observableProto.observeOn = function (scheduler) {
|
2035
|
+
var source = this;
|
2036
|
+
return new AnonymousObservable(function (observer) {
|
2037
|
+
return source.subscribe(new ObserveOnObserver(scheduler, observer));
|
2038
|
+
});
|
2039
|
+
};
|
2027
2040
|
|
2028
|
-
|
2029
|
-
|
2030
|
-
|
2041
|
+
/**
|
2042
|
+
* Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler. This operation is not commonly used;
|
2043
|
+
* see the remarks section for more information on the distinction between subscribeOn and observeOn.
|
2031
2044
|
|
2032
|
-
|
2033
|
-
|
2045
|
+
* This only performs the side-effects of subscription and unsubscription on the specified scheduler. In order to invoke observer
|
2046
|
+
* callbacks on a scheduler, use observeOn.
|
2034
2047
|
|
2035
|
-
|
2036
|
-
|
2037
|
-
|
2038
|
-
|
2039
|
-
|
2040
|
-
|
2041
|
-
|
2042
|
-
|
2043
|
-
|
2044
|
-
|
2045
|
-
|
2046
|
-
|
2047
|
-
|
2048
|
-
|
2048
|
+
* @param {Scheduler} scheduler Scheduler to perform subscription and unsubscription actions on.
|
2049
|
+
* @returns {Observable} The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler.
|
2050
|
+
*/
|
2051
|
+
observableProto.subscribeOn = function (scheduler) {
|
2052
|
+
var source = this;
|
2053
|
+
return new AnonymousObservable(function (observer) {
|
2054
|
+
var m = new SingleAssignmentDisposable(), d = new SerialDisposable();
|
2055
|
+
d.setDisposable(m);
|
2056
|
+
m.setDisposable(scheduler.schedule(function () {
|
2057
|
+
d.setDisposable(new ScheduledDisposable(scheduler, source.subscribe(observer)));
|
2058
|
+
}));
|
2059
|
+
return d;
|
2060
|
+
});
|
2061
|
+
};
|
2049
2062
|
|
2050
2063
|
/**
|
2051
2064
|
* Converts a Promise to an Observable sequence
|
@@ -2068,38 +2081,32 @@
|
|
2068
2081
|
return subject;
|
2069
2082
|
});
|
2070
2083
|
};
|
2071
|
-
|
2072
|
-
|
2073
|
-
|
2074
|
-
|
2075
|
-
|
2076
|
-
|
2077
|
-
|
2078
|
-
|
2079
|
-
|
2080
|
-
|
2081
|
-
|
2082
|
-
|
2083
|
-
|
2084
|
-
|
2085
|
-
|
2086
|
-
|
2087
|
-
|
2088
|
-
|
2089
|
-
|
2090
|
-
|
2091
|
-
|
2092
|
-
|
2093
|
-
|
2094
|
-
|
2095
|
-
|
2096
|
-
|
2097
|
-
if (hasValue) {
|
2098
|
-
resolve(value);
|
2099
|
-
}
|
2100
|
-
});
|
2101
|
-
});
|
2102
|
-
};
|
2084
|
+
/*
|
2085
|
+
* Converts an existing observable sequence to an ES6 Compatible Promise
|
2086
|
+
* @example
|
2087
|
+
* var promise = Rx.Observable.return(42).toPromise(RSVP.Promise);
|
2088
|
+
*
|
2089
|
+
* // With config
|
2090
|
+
* Rx.config.Promise = RSVP.Promise;
|
2091
|
+
* var promise = Rx.Observable.return(42).toPromise();
|
2092
|
+
* @param {Function} [promiseCtor] The constructor of the promise. If not provided, it looks for it in Rx.config.Promise.
|
2093
|
+
* @returns {Promise} An ES6 compatible promise with the last value from the observable sequence.
|
2094
|
+
*/
|
2095
|
+
observableProto.toPromise = function (promiseCtor) {
|
2096
|
+
promiseCtor || (promiseCtor = Rx.config.Promise);
|
2097
|
+
if (!promiseCtor) { throw new TypeError('Promise type not provided nor in Rx.config.Promise'); }
|
2098
|
+
var source = this;
|
2099
|
+
return new promiseCtor(function (resolve, reject) {
|
2100
|
+
// No cancellation can be done
|
2101
|
+
var value, hasValue = false;
|
2102
|
+
source.subscribe(function (v) {
|
2103
|
+
value = v;
|
2104
|
+
hasValue = true;
|
2105
|
+
}, reject, function () {
|
2106
|
+
hasValue && resolve(value);
|
2107
|
+
});
|
2108
|
+
});
|
2109
|
+
};
|
2103
2110
|
/**
|
2104
2111
|
* Creates a list from an observable sequence.
|
2105
2112
|
* @returns An observable sequence containing a single element with a list containing all the elements of the source sequence.
|
@@ -2328,15 +2335,15 @@
|
|
2328
2335
|
});
|
2329
2336
|
};
|
2330
2337
|
|
2331
|
-
|
2332
|
-
|
2333
|
-
|
2334
|
-
|
2335
|
-
|
2336
|
-
|
2337
|
-
|
2338
|
-
|
2339
|
-
|
2338
|
+
/**
|
2339
|
+
* Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins).
|
2340
|
+
* @returns {Observable} An observable sequence whose observers will never get called.
|
2341
|
+
*/
|
2342
|
+
var observableNever = Observable.never = function () {
|
2343
|
+
return new AnonymousObservable(function () {
|
2344
|
+
return disposableEmpty;
|
2345
|
+
});
|
2346
|
+
};
|
2340
2347
|
|
2341
2348
|
/**
|
2342
2349
|
* This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.
|
@@ -2429,16 +2436,12 @@
|
|
2429
2436
|
|
2430
2437
|
/**
|
2431
2438
|
* Returns an observable sequence that terminates with an exception, using the specified scheduler to send out the single onError message.
|
2432
|
-
* There is an alias to this method called '
|
2433
|
-
*
|
2434
|
-
* @example
|
2435
|
-
* var res = Rx.Observable.throw(new Error('Error'));
|
2436
|
-
* var res = Rx.Observable.throw(new Error('Error'), Rx.Scheduler.timeout);
|
2439
|
+
* There is an alias to this method called 'throwError' for browsers <IE9.
|
2437
2440
|
* @param {Mixed} exception An object used for the sequence's termination.
|
2438
2441
|
* @param {Scheduler} scheduler Scheduler to send the exceptional termination call on. If not specified, defaults to Scheduler.immediate.
|
2439
2442
|
* @returns {Observable} The observable sequence that terminates exceptionally with the specified exception object.
|
2440
2443
|
*/
|
2441
|
-
var observableThrow = Observable['throw'] = Observable.throwException = function (exception, scheduler) {
|
2444
|
+
var observableThrow = Observable['throw'] = Observable.throwException = Observable.throwError = function (exception, scheduler) {
|
2442
2445
|
isScheduler(scheduler) || (scheduler = immediateScheduler);
|
2443
2446
|
return new AnonymousObservable(function (observer) {
|
2444
2447
|
return scheduler.schedule(function () {
|
@@ -2448,10 +2451,7 @@
|
|
2448
2451
|
};
|
2449
2452
|
|
2450
2453
|
/**
|
2451
|
-
*
|
2452
|
-
*
|
2453
|
-
* @example
|
2454
|
-
* var res = Rx.Observable.using(function () { return new AsyncSubject(); }, function (s) { return s; });
|
2454
|
+
* Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence's lifetime.
|
2455
2455
|
* @param {Function} resourceFactory Factory function to obtain a resource object.
|
2456
2456
|
* @param {Function} observableFactory Factory function to obtain an observable sequence that depends on the obtained resource.
|
2457
2457
|
* @returns {Observable} An observable sequence whose lifetime controls the lifetime of the dependent resource object.
|
@@ -2461,9 +2461,7 @@
|
|
2461
2461
|
var disposable = disposableEmpty, resource, source;
|
2462
2462
|
try {
|
2463
2463
|
resource = resourceFactory();
|
2464
|
-
|
2465
|
-
disposable = resource;
|
2466
|
-
}
|
2464
|
+
resource && (disposable = resource);
|
2467
2465
|
source = observableFactory(resource);
|
2468
2466
|
} catch (exception) {
|
2469
2467
|
return new CompositeDisposable(observableThrow(exception).subscribe(observer), disposable);
|
@@ -2820,20 +2818,16 @@
|
|
2820
2818
|
var innerSubscription = new SingleAssignmentDisposable();
|
2821
2819
|
group.add(innerSubscription);
|
2822
2820
|
|
2823
|
-
// Check
|
2824
|
-
|
2825
|
-
innerSource = observableFromPromise(innerSource);
|
2826
|
-
}
|
2821
|
+
// Check for promises support
|
2822
|
+
isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
|
2827
2823
|
|
2828
|
-
innerSubscription.setDisposable(innerSource.subscribe(function (
|
2829
|
-
|
2830
|
-
|
2831
|
-
group.remove(innerSubscription);
|
2832
|
-
if (isStopped && group.length === 1) { observer.onCompleted(); }
|
2824
|
+
innerSubscription.setDisposable(innerSource.subscribe(observer.onNext.bind(observer), observer.onError.bind(observer), function () {
|
2825
|
+
group.remove(innerSubscription);
|
2826
|
+
isStopped && group.length === 1 && observer.onCompleted();
|
2833
2827
|
}));
|
2834
2828
|
}, observer.onError.bind(observer), function () {
|
2835
2829
|
isStopped = true;
|
2836
|
-
|
2830
|
+
group.length === 1 && observer.onCompleted();
|
2837
2831
|
}));
|
2838
2832
|
return group;
|
2839
2833
|
});
|
@@ -2845,9 +2839,7 @@
|
|
2845
2839
|
* @returns {Observable} An observable sequence that concatenates the first and second sequence, even if the first sequence terminates exceptionally.
|
2846
2840
|
*/
|
2847
2841
|
observableProto.onErrorResumeNext = function (second) {
|
2848
|
-
if (!second) {
|
2849
|
-
throw new Error('Second observable is required');
|
2850
|
-
}
|
2842
|
+
if (!second) { throw new Error('Second observable is required'); }
|
2851
2843
|
return onErrorResumeNext([this, second]);
|
2852
2844
|
};
|
2853
2845
|
|
@@ -2870,11 +2862,7 @@
|
|
2870
2862
|
isPromise(current) && (current = observableFromPromise(current));
|
2871
2863
|
d = new SingleAssignmentDisposable();
|
2872
2864
|
subscription.setDisposable(d);
|
2873
|
-
d.setDisposable(current.subscribe(observer.onNext.bind(observer),
|
2874
|
-
self();
|
2875
|
-
}, function () {
|
2876
|
-
self();
|
2877
|
-
}));
|
2865
|
+
d.setDisposable(current.subscribe(observer.onNext.bind(observer), self, self));
|
2878
2866
|
} else {
|
2879
2867
|
observer.onCompleted();
|
2880
2868
|
}
|
@@ -2913,52 +2901,44 @@
|
|
2913
2901
|
});
|
2914
2902
|
};
|
2915
2903
|
|
2916
|
-
|
2917
|
-
|
2918
|
-
|
2919
|
-
|
2920
|
-
|
2921
|
-
|
2922
|
-
|
2923
|
-
|
2924
|
-
|
2925
|
-
|
2926
|
-
|
2927
|
-
|
2928
|
-
|
2929
|
-
|
2930
|
-
|
2931
|
-
|
2932
|
-
|
2933
|
-
|
2934
|
-
|
2935
|
-
}
|
2904
|
+
/**
|
2905
|
+
* Transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
|
2906
|
+
* @returns {Observable} The observable sequence that at any point in time produces the elements of the most recent inner observable sequence that has been received.
|
2907
|
+
*/
|
2908
|
+
observableProto['switch'] = observableProto.switchLatest = function () {
|
2909
|
+
var sources = this;
|
2910
|
+
return new AnonymousObservable(function (observer) {
|
2911
|
+
var hasLatest = false,
|
2912
|
+
innerSubscription = new SerialDisposable(),
|
2913
|
+
isStopped = false,
|
2914
|
+
latest = 0,
|
2915
|
+
subscription = sources.subscribe(
|
2916
|
+
function (innerSource) {
|
2917
|
+
var d = new SingleAssignmentDisposable(), id = ++latest;
|
2918
|
+
hasLatest = true;
|
2919
|
+
innerSubscription.setDisposable(d);
|
2920
|
+
|
2921
|
+
// Check if Promise or Observable
|
2922
|
+
isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
|
2936
2923
|
|
2937
|
-
|
2938
|
-
|
2939
|
-
|
2940
|
-
|
2941
|
-
|
2942
|
-
|
2943
|
-
|
2944
|
-
|
2945
|
-
|
2946
|
-
|
2947
|
-
|
2948
|
-
|
2949
|
-
|
2950
|
-
|
2951
|
-
|
2952
|
-
|
2953
|
-
|
2954
|
-
|
2955
|
-
if (!hasLatest) {
|
2956
|
-
observer.onCompleted();
|
2957
|
-
}
|
2958
|
-
});
|
2959
|
-
return new CompositeDisposable(subscription, innerSubscription);
|
2960
|
-
});
|
2961
|
-
};
|
2924
|
+
d.setDisposable(innerSource.subscribe(
|
2925
|
+
function (x) { latest === id && observer.onNext(x); },
|
2926
|
+
function (e) { latest === id && observer.onError(e); },
|
2927
|
+
function () {
|
2928
|
+
if (latest === id) {
|
2929
|
+
hasLatest = false;
|
2930
|
+
isStopped && observer.onCompleted();
|
2931
|
+
}
|
2932
|
+
}));
|
2933
|
+
},
|
2934
|
+
observer.onError.bind(observer),
|
2935
|
+
function () {
|
2936
|
+
isStopped = true;
|
2937
|
+
!hasLatest && observer.onCompleted();
|
2938
|
+
});
|
2939
|
+
return new CompositeDisposable(subscription, innerSubscription);
|
2940
|
+
});
|
2941
|
+
};
|
2962
2942
|
|
2963
2943
|
/**
|
2964
2944
|
* Returns the values from the source observable sequence until the other observable sequence produces a value.
|
@@ -3123,16 +3103,13 @@
|
|
3123
3103
|
});
|
3124
3104
|
};
|
3125
3105
|
|
3126
|
-
|
3127
|
-
|
3128
|
-
|
3129
|
-
|
3130
|
-
|
3131
|
-
|
3132
|
-
|
3133
|
-
return source.subscribe(observer);
|
3134
|
-
});
|
3135
|
-
};
|
3106
|
+
/**
|
3107
|
+
* Hides the identity of an observable sequence.
|
3108
|
+
* @returns {Observable} An observable sequence that hides the identity of the source sequence.
|
3109
|
+
*/
|
3110
|
+
observableProto.asObservable = function () {
|
3111
|
+
return new AnonymousObservable(this.subscribe.bind(this));
|
3112
|
+
};
|
3136
3113
|
|
3137
3114
|
/**
|
3138
3115
|
* Projects each element of an observable sequence into zero or more buffers which are produced based on element count information.
|
@@ -3297,35 +3274,35 @@
|
|
3297
3274
|
});
|
3298
3275
|
};
|
3299
3276
|
|
3300
|
-
|
3301
|
-
|
3302
|
-
|
3303
|
-
|
3304
|
-
|
3305
|
-
|
3306
|
-
|
3307
|
-
|
3308
|
-
|
3309
|
-
|
3277
|
+
/**
|
3278
|
+
* Ignores all elements in an observable sequence leaving only the termination messages.
|
3279
|
+
* @returns {Observable} An empty observable sequence that signals termination, successful or exceptional, of the source sequence.
|
3280
|
+
*/
|
3281
|
+
observableProto.ignoreElements = function () {
|
3282
|
+
var source = this;
|
3283
|
+
return new AnonymousObservable(function (observer) {
|
3284
|
+
return source.subscribe(noop, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
3285
|
+
});
|
3286
|
+
};
|
3310
3287
|
|
3311
|
-
|
3312
|
-
|
3313
|
-
|
3314
|
-
|
3315
|
-
|
3316
|
-
|
3317
|
-
|
3318
|
-
|
3319
|
-
|
3320
|
-
|
3321
|
-
|
3322
|
-
|
3323
|
-
|
3324
|
-
|
3325
|
-
|
3326
|
-
|
3327
|
-
|
3328
|
-
|
3288
|
+
/**
|
3289
|
+
* Materializes the implicit notifications of an observable sequence as explicit notification values.
|
3290
|
+
* @returns {Observable} An observable sequence containing the materialized notification values from the source sequence.
|
3291
|
+
*/
|
3292
|
+
observableProto.materialize = function () {
|
3293
|
+
var source = this;
|
3294
|
+
return new AnonymousObservable(function (observer) {
|
3295
|
+
return source.subscribe(function (value) {
|
3296
|
+
observer.onNext(notificationCreateOnNext(value));
|
3297
|
+
}, function (e) {
|
3298
|
+
observer.onNext(notificationCreateOnError(e));
|
3299
|
+
observer.onCompleted();
|
3300
|
+
}, function () {
|
3301
|
+
observer.onNext(notificationCreateOnCompleted());
|
3302
|
+
observer.onCompleted();
|
3303
|
+
});
|
3304
|
+
});
|
3305
|
+
};
|
3329
3306
|
|
3330
3307
|
/**
|
3331
3308
|
* Repeats the observable sequence a specified number of times. If the repeat count is not specified, the sequence repeats indefinitely.
|
@@ -3354,106 +3331,94 @@
|
|
3354
3331
|
return enumerableRepeat(this, retryCount).catchException();
|
3355
3332
|
};
|
3356
3333
|
|
3357
|
-
|
3358
|
-
|
3359
|
-
|
3360
|
-
|
3361
|
-
|
3362
|
-
|
3363
|
-
|
3364
|
-
|
3365
|
-
|
3366
|
-
|
3367
|
-
|
3368
|
-
|
3369
|
-
|
3370
|
-
|
3371
|
-
|
3372
|
-
|
3373
|
-
|
3374
|
-
|
3334
|
+
/**
|
3335
|
+
* Applies an accumulator function over an observable sequence and returns each intermediate result. The optional seed value is used as the initial accumulator value.
|
3336
|
+
* For aggregation behavior with no intermediate results, see Observable.aggregate.
|
3337
|
+
* @example
|
3338
|
+
* var res = source.scan(function (acc, x) { return acc + x; });
|
3339
|
+
* var res = source.scan(0, function (acc, x) { return acc + x; });
|
3340
|
+
* @param {Mixed} [seed] The initial accumulator value.
|
3341
|
+
* @param {Function} accumulator An accumulator function to be invoked on each element.
|
3342
|
+
* @returns {Observable} An observable sequence containing the accumulated values.
|
3343
|
+
*/
|
3344
|
+
observableProto.scan = function () {
|
3345
|
+
var hasSeed = false, seed, accumulator, source = this;
|
3346
|
+
if (arguments.length === 2) {
|
3347
|
+
hasSeed = true;
|
3348
|
+
seed = arguments[0];
|
3349
|
+
accumulator = arguments[1];
|
3350
|
+
} else {
|
3351
|
+
accumulator = arguments[0];
|
3352
|
+
}
|
3353
|
+
return new AnonymousObservable(function (observer) {
|
3354
|
+
var hasAccumulation, accumulation, hasValue;
|
3355
|
+
return source.subscribe (
|
3356
|
+
function (x) {
|
3357
|
+
!hasValue && (hasValue = true);
|
3358
|
+
try {
|
3359
|
+
if (hasAccumulation) {
|
3360
|
+
accumulation = accumulator(accumulation, x);
|
3361
|
+
} else {
|
3362
|
+
accumulation = hasSeed ? accumulator(seed, x) : x;
|
3363
|
+
hasAccumulation = true;
|
3364
|
+
}
|
3365
|
+
} catch (e) {
|
3366
|
+
observer.onError(e);
|
3367
|
+
return;
|
3368
|
+
}
|
3369
|
+
|
3370
|
+
observer.onNext(accumulation);
|
3371
|
+
},
|
3372
|
+
observer.onError.bind(observer),
|
3373
|
+
function () {
|
3374
|
+
!hasValue && hasSeed && observer.onNext(seed);
|
3375
|
+
observer.onCompleted();
|
3375
3376
|
}
|
3376
|
-
|
3377
|
-
|
3378
|
-
|
3379
|
-
function (x) {
|
3380
|
-
try {
|
3381
|
-
if (!hasValue) {
|
3382
|
-
hasValue = true;
|
3383
|
-
}
|
3384
|
-
|
3385
|
-
if (hasAccumulation) {
|
3386
|
-
accumulation = accumulator(accumulation, x);
|
3387
|
-
} else {
|
3388
|
-
accumulation = hasSeed ? accumulator(seed, x) : x;
|
3389
|
-
hasAccumulation = true;
|
3390
|
-
}
|
3391
|
-
} catch (e) {
|
3392
|
-
observer.onError(e);
|
3393
|
-
return;
|
3394
|
-
}
|
3395
|
-
|
3396
|
-
observer.onNext(accumulation);
|
3397
|
-
},
|
3398
|
-
observer.onError.bind(observer),
|
3399
|
-
function () {
|
3400
|
-
if (!hasValue && hasSeed) {
|
3401
|
-
observer.onNext(seed);
|
3402
|
-
}
|
3403
|
-
observer.onCompleted();
|
3404
|
-
}
|
3405
|
-
);
|
3406
|
-
});
|
3407
|
-
};
|
3377
|
+
);
|
3378
|
+
});
|
3379
|
+
};
|
3408
3380
|
|
3409
|
-
|
3410
|
-
|
3411
|
-
|
3412
|
-
|
3413
|
-
|
3414
|
-
|
3415
|
-
|
3416
|
-
|
3417
|
-
|
3418
|
-
|
3419
|
-
|
3420
|
-
|
3421
|
-
|
3422
|
-
|
3423
|
-
|
3424
|
-
|
3425
|
-
|
3426
|
-
|
3427
|
-
});
|
3428
|
-
};
|
3381
|
+
/**
|
3382
|
+
* Bypasses a specified number of elements at the end of an observable sequence.
|
3383
|
+
* @description
|
3384
|
+
* This operator accumulates a queue with a length enough to store the first `count` elements. As more elements are
|
3385
|
+
* received, elements are taken from the front of the queue and produced on the result sequence. This causes elements to be delayed.
|
3386
|
+
* @param count Number of elements to bypass at the end of the source sequence.
|
3387
|
+
* @returns {Observable} An observable sequence containing the source sequence elements except for the bypassed ones at the end.
|
3388
|
+
*/
|
3389
|
+
observableProto.skipLast = function (count) {
|
3390
|
+
var source = this;
|
3391
|
+
return new AnonymousObservable(function (observer) {
|
3392
|
+
var q = [];
|
3393
|
+
return source.subscribe(function (x) {
|
3394
|
+
q.push(x);
|
3395
|
+
q.length > count && observer.onNext(q.shift());
|
3396
|
+
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
3397
|
+
});
|
3398
|
+
};
|
3429
3399
|
|
3430
|
-
|
3431
|
-
|
3432
|
-
|
3433
|
-
|
3434
|
-
|
3435
|
-
|
3436
|
-
|
3437
|
-
|
3438
|
-
|
3439
|
-
|
3440
|
-
|
3441
|
-
|
3442
|
-
|
3443
|
-
|
3444
|
-
|
3445
|
-
|
3446
|
-
|
3447
|
-
|
3448
|
-
|
3449
|
-
};
|
3400
|
+
/**
|
3401
|
+
* Prepends a sequence of values to an observable sequence with an optional scheduler and an argument list of values to prepend.
|
3402
|
+
* @example
|
3403
|
+
* var res = source.startWith(1, 2, 3);
|
3404
|
+
* var res = source.startWith(Rx.Scheduler.timeout, 1, 2, 3);
|
3405
|
+
* @param {Arguments} args The specified values to prepend to the observable sequence
|
3406
|
+
* @returns {Observable} The source sequence prepended with the specified values.
|
3407
|
+
*/
|
3408
|
+
observableProto.startWith = function () {
|
3409
|
+
var values, scheduler, start = 0;
|
3410
|
+
if (!!arguments.length && isScheduler(arguments[0])) {
|
3411
|
+
scheduler = arguments[0];
|
3412
|
+
start = 1;
|
3413
|
+
} else {
|
3414
|
+
scheduler = immediateScheduler;
|
3415
|
+
}
|
3416
|
+
values = slice.call(arguments, start);
|
3417
|
+
return enumerableFor([observableFromArray(values, scheduler), this]).concat();
|
3418
|
+
};
|
3450
3419
|
|
3451
3420
|
/**
|
3452
3421
|
* Returns a specified number of contiguous elements from the end of an observable sequence.
|
3453
|
-
*
|
3454
|
-
* @example
|
3455
|
-
* var res = source.takeLast(5);
|
3456
|
-
*
|
3457
3422
|
* @description
|
3458
3423
|
* This operator accumulates a buffer with a length enough to store elements count elements. Upon completion of
|
3459
3424
|
* the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.
|
@@ -3755,14 +3720,14 @@
|
|
3755
3720
|
});
|
3756
3721
|
};
|
3757
3722
|
|
3758
|
-
|
3759
|
-
|
3760
|
-
|
3761
|
-
|
3762
|
-
|
3763
|
-
|
3764
|
-
|
3765
|
-
|
3723
|
+
/**
|
3724
|
+
* Retrieves the value of a specified property from all elements in the Observable sequence.
|
3725
|
+
* @param {String} prop The property to pluck.
|
3726
|
+
* @returns {Observable} Returns a new Observable sequence of property values.
|
3727
|
+
*/
|
3728
|
+
observableProto.pluck = function (prop) {
|
3729
|
+
return this.map(function (x) { return x[prop]; });
|
3730
|
+
};
|
3766
3731
|
|
3767
3732
|
/**
|
3768
3733
|
* Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
|
@@ -3858,133 +3823,118 @@
|
|
3858
3823
|
flatMap(this, function () { return selector; });
|
3859
3824
|
};
|
3860
3825
|
|
3861
|
-
|
3862
|
-
|
3863
|
-
|
3864
|
-
|
3865
|
-
|
3866
|
-
|
3867
|
-
|
3868
|
-
|
3869
|
-
|
3870
|
-
|
3871
|
-
|
3826
|
+
/**
|
3827
|
+
* Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then
|
3828
|
+
* transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
|
3829
|
+
* @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
|
3830
|
+
* @param {Any} [thisArg] Object to use as this when executing callback.
|
3831
|
+
* @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences
|
3832
|
+
* and that at any point in time produces the elements of the most recent inner observable sequence that has been received.
|
3833
|
+
*/
|
3834
|
+
observableProto.selectSwitch = observableProto.flatMapLatest = observableProto.switchMap = function (selector, thisArg) {
|
3835
|
+
return this.select(selector, thisArg).switchLatest();
|
3836
|
+
};
|
3872
3837
|
|
3873
|
-
|
3874
|
-
|
3875
|
-
|
3876
|
-
|
3877
|
-
|
3878
|
-
|
3879
|
-
|
3880
|
-
|
3838
|
+
/**
|
3839
|
+
* Bypasses a specified number of elements in an observable sequence and then returns the remaining elements.
|
3840
|
+
* @param {Number} count The number of elements to skip before returning the remaining elements.
|
3841
|
+
* @returns {Observable} An observable sequence that contains the elements that occur after the specified index in the input sequence.
|
3842
|
+
*/
|
3843
|
+
observableProto.skip = function (count) {
|
3844
|
+
if (count < 0) { throw new Error(argumentOutOfRange); }
|
3845
|
+
var source = this;
|
3846
|
+
return new AnonymousObservable(function (observer) {
|
3847
|
+
var remaining = count;
|
3848
|
+
return source.subscribe(function (x) {
|
3849
|
+
if (remaining <= 0) {
|
3850
|
+
observer.onNext(x);
|
3851
|
+
} else {
|
3852
|
+
remaining--;
|
3853
|
+
}
|
3854
|
+
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
3855
|
+
});
|
3856
|
+
};
|
3857
|
+
|
3858
|
+
/**
|
3859
|
+
* Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
|
3860
|
+
* The element's index is used in the logic of the predicate function.
|
3861
|
+
*
|
3862
|
+
* var res = source.skipWhile(function (value) { return value < 10; });
|
3863
|
+
* var res = source.skipWhile(function (value, index) { return value < 10 || index < 10; });
|
3864
|
+
* @param {Function} predicate A function to test each element for a condition; the second parameter of the function represents the index of the source element.
|
3865
|
+
* @param {Any} [thisArg] Object to use as this when executing callback.
|
3866
|
+
* @returns {Observable} An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate.
|
3867
|
+
*/
|
3868
|
+
observableProto.skipWhile = function (predicate, thisArg) {
|
3869
|
+
var source = this;
|
3870
|
+
return new AnonymousObservable(function (observer) {
|
3871
|
+
var i = 0, running = false;
|
3872
|
+
return source.subscribe(function (x) {
|
3873
|
+
if (!running) {
|
3874
|
+
try {
|
3875
|
+
running = !predicate.call(thisArg, x, i++, source);
|
3876
|
+
} catch (e) {
|
3877
|
+
observer.onError(e);
|
3878
|
+
return;
|
3879
|
+
}
|
3881
3880
|
}
|
3882
|
-
|
3883
|
-
|
3884
|
-
|
3885
|
-
|
3886
|
-
if (remaining <= 0) {
|
3887
|
-
observer.onNext(x);
|
3888
|
-
} else {
|
3889
|
-
remaining--;
|
3890
|
-
}
|
3891
|
-
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
3892
|
-
});
|
3893
|
-
};
|
3881
|
+
running && observer.onNext(x);
|
3882
|
+
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
3883
|
+
});
|
3884
|
+
};
|
3894
3885
|
|
3895
|
-
|
3896
|
-
|
3897
|
-
|
3898
|
-
|
3899
|
-
|
3900
|
-
|
3901
|
-
|
3902
|
-
|
3903
|
-
|
3904
|
-
|
3905
|
-
|
3906
|
-
|
3907
|
-
|
3908
|
-
|
3909
|
-
|
3910
|
-
|
3911
|
-
|
3912
|
-
|
3913
|
-
|
3914
|
-
|
3915
|
-
|
3916
|
-
|
3917
|
-
|
3918
|
-
if (running) {
|
3919
|
-
observer.onNext(x);
|
3920
|
-
}
|
3921
|
-
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
3922
|
-
});
|
3923
|
-
};
|
3886
|
+
/**
|
3887
|
+
* Returns a specified number of contiguous elements from the start of an observable sequence, using the specified scheduler for the edge case of take(0).
|
3888
|
+
*
|
3889
|
+
* var res = source.take(5);
|
3890
|
+
* var res = source.take(0, Rx.Scheduler.timeout);
|
3891
|
+
* @param {Number} count The number of elements to return.
|
3892
|
+
* @param {Scheduler} [scheduler] Scheduler used to produce an OnCompleted message in case <paramref name="count count</paramref> is set to 0.
|
3893
|
+
* @returns {Observable} An observable sequence that contains the specified number of elements from the start of the input sequence.
|
3894
|
+
*/
|
3895
|
+
observableProto.take = function (count, scheduler) {
|
3896
|
+
if (count < 0) { throw new RangeError(argumentOutOfRange); }
|
3897
|
+
if (count === 0) { return observableEmpty(scheduler); }
|
3898
|
+
var observable = this;
|
3899
|
+
return new AnonymousObservable(function (observer) {
|
3900
|
+
var remaining = count;
|
3901
|
+
return observable.subscribe(function (x) {
|
3902
|
+
if (remaining-- > 0) {
|
3903
|
+
observer.onNext(x);
|
3904
|
+
remaining === 0 && observer.onCompleted();
|
3905
|
+
}
|
3906
|
+
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
3907
|
+
});
|
3908
|
+
};
|
3924
3909
|
|
3925
|
-
|
3926
|
-
|
3927
|
-
|
3928
|
-
|
3929
|
-
|
3930
|
-
|
3931
|
-
|
3932
|
-
|
3933
|
-
|
3934
|
-
|
3935
|
-
|
3936
|
-
|
3937
|
-
|
3938
|
-
|
3939
|
-
|
3910
|
+
/**
|
3911
|
+
* Returns elements from an observable sequence as long as a specified condition is true.
|
3912
|
+
* The element's index is used in the logic of the predicate function.
|
3913
|
+
* @param {Function} predicate A function to test each element for a condition; the second parameter of the function represents the index of the source element.
|
3914
|
+
* @param {Any} [thisArg] Object to use as this when executing callback.
|
3915
|
+
* @returns {Observable} An observable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes.
|
3916
|
+
*/
|
3917
|
+
observableProto.takeWhile = function (predicate, thisArg) {
|
3918
|
+
var observable = this;
|
3919
|
+
return new AnonymousObservable(function (observer) {
|
3920
|
+
var i = 0, running = true;
|
3921
|
+
return observable.subscribe(function (x) {
|
3922
|
+
if (running) {
|
3923
|
+
try {
|
3924
|
+
running = predicate.call(thisArg, x, i++, observable);
|
3925
|
+
} catch (e) {
|
3926
|
+
observer.onError(e);
|
3927
|
+
return;
|
3928
|
+
}
|
3929
|
+
if (running) {
|
3930
|
+
observer.onNext(x);
|
3931
|
+
} else {
|
3932
|
+
observer.onCompleted();
|
3933
|
+
}
|
3940
3934
|
}
|
3941
|
-
|
3942
|
-
|
3943
|
-
|
3944
|
-
return observable.subscribe(function (x) {
|
3945
|
-
if (remaining > 0) {
|
3946
|
-
remaining--;
|
3947
|
-
observer.onNext(x);
|
3948
|
-
if (remaining === 0) {
|
3949
|
-
observer.onCompleted();
|
3950
|
-
}
|
3951
|
-
}
|
3952
|
-
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
3953
|
-
});
|
3954
|
-
};
|
3955
|
-
|
3956
|
-
/**
|
3957
|
-
* Returns elements from an observable sequence as long as a specified condition is true.
|
3958
|
-
* The element's index is used in the logic of the predicate function.
|
3959
|
-
*
|
3960
|
-
* @example
|
3961
|
-
* var res = source.takeWhile(function (value) { return value < 10; });
|
3962
|
-
* var res = source.takeWhile(function (value, index) { return value < 10 || index < 10; });
|
3963
|
-
* @param {Function} predicate A function to test each element for a condition; the second parameter of the function represents the index of the source element.
|
3964
|
-
* @param {Any} [thisArg] Object to use as this when executing callback.
|
3965
|
-
* @returns {Observable} An observable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes.
|
3966
|
-
*/
|
3967
|
-
observableProto.takeWhile = function (predicate, thisArg) {
|
3968
|
-
var observable = this;
|
3969
|
-
return new AnonymousObservable(function (observer) {
|
3970
|
-
var i = 0, running = true;
|
3971
|
-
return observable.subscribe(function (x) {
|
3972
|
-
if (running) {
|
3973
|
-
try {
|
3974
|
-
running = predicate.call(thisArg, x, i++, observable);
|
3975
|
-
} catch (e) {
|
3976
|
-
observer.onError(e);
|
3977
|
-
return;
|
3978
|
-
}
|
3979
|
-
if (running) {
|
3980
|
-
observer.onNext(x);
|
3981
|
-
} else {
|
3982
|
-
observer.onCompleted();
|
3983
|
-
}
|
3984
|
-
}
|
3985
|
-
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
3986
|
-
});
|
3987
|
-
};
|
3935
|
+
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
3936
|
+
});
|
3937
|
+
};
|
3988
3938
|
|
3989
3939
|
/**
|
3990
3940
|
* Filters the elements of an observable sequence based on a predicate by incorporating the element's index.
|