rxjs-rails 2.3.9 → 2.3.10

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.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rxjs/rails/version.rb +1 -1
  3. data/vendor/assets/javascripts/rx.aggregates.js +174 -204
  4. data/vendor/assets/javascripts/rx.aggregates.min.js +1 -1
  5. data/vendor/assets/javascripts/rx.all.compat.js +1626 -1528
  6. data/vendor/assets/javascripts/rx.all.compat.min.js +3 -3
  7. data/vendor/assets/javascripts/rx.all.js +1624 -1526
  8. data/vendor/assets/javascripts/rx.all.min.js +3 -3
  9. data/vendor/assets/javascripts/rx.async.compat.js +241 -0
  10. data/vendor/assets/javascripts/rx.async.compat.min.js +1 -1
  11. data/vendor/assets/javascripts/rx.async.js +241 -0
  12. data/vendor/assets/javascripts/rx.async.min.js +1 -1
  13. data/vendor/assets/javascripts/rx.backpressure.js +3 -3
  14. data/vendor/assets/javascripts/rx.backpressure.min.js +1 -1
  15. data/vendor/assets/javascripts/rx.binding.js +350 -378
  16. data/vendor/assets/javascripts/rx.binding.min.js +1 -1
  17. data/vendor/assets/javascripts/rx.coincidence.js +16 -21
  18. data/vendor/assets/javascripts/rx.compat.js +633 -683
  19. data/vendor/assets/javascripts/rx.compat.min.js +2 -2
  20. data/vendor/assets/javascripts/rx.js +633 -683
  21. data/vendor/assets/javascripts/rx.lite.compat.js +941 -1137
  22. data/vendor/assets/javascripts/rx.lite.compat.min.js +2 -2
  23. data/vendor/assets/javascripts/rx.lite.extras.js +58 -74
  24. data/vendor/assets/javascripts/rx.lite.extras.min.js +1 -1
  25. data/vendor/assets/javascripts/rx.lite.js +941 -1137
  26. data/vendor/assets/javascripts/rx.lite.min.js +2 -2
  27. data/vendor/assets/javascripts/rx.min.js +2 -2
  28. data/vendor/assets/javascripts/rx.time.js +182 -212
  29. data/vendor/assets/javascripts/rx.time.min.js +1 -1
  30. 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, [], []);
@@ -546,101 +550,91 @@ if (!Array.prototype.forEach) {
546
550
  };
547
551
  }
548
552
 
549
- // Collections
550
- var IndexedItem = function (id, value) {
551
- this.id = id;
552
- this.value = value;
553
- };
553
+ // Collections
554
+ function IndexedItem(id, value) {
555
+ this.id = id;
556
+ this.value = value;
557
+ }
554
558
 
555
- IndexedItem.prototype.compareTo = function (other) {
556
- var c = this.value.compareTo(other.value);
557
- if (c === 0) {
558
- c = this.id - other.id;
559
- }
560
- return c;
561
- };
559
+ IndexedItem.prototype.compareTo = function (other) {
560
+ var c = this.value.compareTo(other.value);
561
+ c === 0 && (c = this.id - other.id);
562
+ return c;
563
+ };
562
564
 
563
- // Priority Queue for Scheduling
564
- var PriorityQueue = Rx.internals.PriorityQueue = function (capacity) {
565
- this.items = new Array(capacity);
566
- this.length = 0;
567
- };
565
+ // Priority Queue for Scheduling
566
+ var PriorityQueue = Rx.internals.PriorityQueue = function (capacity) {
567
+ this.items = new Array(capacity);
568
+ this.length = 0;
569
+ };
568
570
 
569
- var priorityProto = PriorityQueue.prototype;
570
- priorityProto.isHigherPriority = function (left, right) {
571
- return this.items[left].compareTo(this.items[right]) < 0;
572
- };
571
+ var priorityProto = PriorityQueue.prototype;
572
+ priorityProto.isHigherPriority = function (left, right) {
573
+ return this.items[left].compareTo(this.items[right]) < 0;
574
+ };
573
575
 
574
- priorityProto.percolate = function (index) {
575
- if (index >= this.length || index < 0) {
576
- return;
577
- }
578
- var parent = index - 1 >> 1;
579
- if (parent < 0 || parent === index) {
580
- return;
581
- }
582
- if (this.isHigherPriority(index, parent)) {
583
- var temp = this.items[index];
584
- this.items[index] = this.items[parent];
585
- this.items[parent] = temp;
586
- this.percolate(parent);
587
- }
588
- };
576
+ priorityProto.percolate = function (index) {
577
+ if (index >= this.length || index < 0) { return; }
578
+ var parent = index - 1 >> 1;
579
+ if (parent < 0 || parent === index) { return; }
580
+ if (this.isHigherPriority(index, parent)) {
581
+ var temp = this.items[index];
582
+ this.items[index] = this.items[parent];
583
+ this.items[parent] = temp;
584
+ this.percolate(parent);
585
+ }
586
+ };
589
587
 
590
- priorityProto.heapify = function (index) {
591
- if (index === undefined) {
592
- index = 0;
593
- }
594
- if (index >= this.length || index < 0) {
595
- return;
596
- }
597
- var left = 2 * index + 1,
598
- right = 2 * index + 2,
599
- first = index;
600
- if (left < this.length && this.isHigherPriority(left, first)) {
601
- first = left;
602
- }
603
- if (right < this.length && this.isHigherPriority(right, first)) {
604
- first = right;
605
- }
606
- if (first !== index) {
607
- var temp = this.items[index];
608
- this.items[index] = this.items[first];
609
- this.items[first] = temp;
610
- this.heapify(first);
611
- }
612
- };
613
-
614
- priorityProto.peek = function () { return this.items[0].value; };
588
+ priorityProto.heapify = function (index) {
589
+ +index || (index = 0);
590
+ if (index >= this.length || index < 0) { return; }
591
+ var left = 2 * index + 1,
592
+ right = 2 * index + 2,
593
+ first = index;
594
+ if (left < this.length && this.isHigherPriority(left, first)) {
595
+ first = left;
596
+ }
597
+ if (right < this.length && this.isHigherPriority(right, first)) {
598
+ first = right;
599
+ }
600
+ if (first !== index) {
601
+ var temp = this.items[index];
602
+ this.items[index] = this.items[first];
603
+ this.items[first] = temp;
604
+ this.heapify(first);
605
+ }
606
+ };
607
+
608
+ priorityProto.peek = function () { return this.items[0].value; };
615
609
 
616
- priorityProto.removeAt = function (index) {
617
- this.items[index] = this.items[--this.length];
618
- delete this.items[this.length];
619
- this.heapify();
620
- };
610
+ priorityProto.removeAt = function (index) {
611
+ this.items[index] = this.items[--this.length];
612
+ delete this.items[this.length];
613
+ this.heapify();
614
+ };
621
615
 
622
- priorityProto.dequeue = function () {
623
- var result = this.peek();
624
- this.removeAt(0);
625
- return result;
626
- };
616
+ priorityProto.dequeue = function () {
617
+ var result = this.peek();
618
+ this.removeAt(0);
619
+ return result;
620
+ };
627
621
 
628
- priorityProto.enqueue = function (item) {
629
- var index = this.length++;
630
- this.items[index] = new IndexedItem(PriorityQueue.count++, item);
631
- this.percolate(index);
632
- };
622
+ priorityProto.enqueue = function (item) {
623
+ var index = this.length++;
624
+ this.items[index] = new IndexedItem(PriorityQueue.count++, item);
625
+ this.percolate(index);
626
+ };
633
627
 
634
- priorityProto.remove = function (item) {
635
- for (var i = 0; i < this.length; i++) {
636
- if (this.items[i].value === item) {
637
- this.removeAt(i);
638
- return true;
639
- }
640
- }
641
- return false;
642
- };
643
- PriorityQueue.count = 0;
628
+ priorityProto.remove = function (item) {
629
+ for (var i = 0; i < this.length; i++) {
630
+ if (this.items[i].value === item) {
631
+ this.removeAt(i);
632
+ return true;
633
+ }
634
+ }
635
+ return false;
636
+ };
637
+ PriorityQueue.count = 0;
644
638
  /**
645
639
  * Represents a group of disposable resources that are disposed together.
646
640
  * @constructor
@@ -709,39 +703,38 @@ if (!Array.prototype.forEach) {
709
703
  return this.disposables.slice(0);
710
704
  };
711
705
 
712
- /**
713
- * Provides a set of static methods for creating Disposables.
714
- *
715
- * @constructor
716
- * @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once.
717
- */
718
- var Disposable = Rx.Disposable = function (action) {
719
- this.isDisposed = false;
720
- this.action = action || noop;
721
- };
706
+ /**
707
+ * Provides a set of static methods for creating Disposables.
708
+ *
709
+ * @constructor
710
+ * @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once.
711
+ */
712
+ var Disposable = Rx.Disposable = function (action) {
713
+ this.isDisposed = false;
714
+ this.action = action || noop;
715
+ };
722
716
 
723
- /** Performs the task of cleaning up resources. */
724
- Disposable.prototype.dispose = function () {
725
- if (!this.isDisposed) {
726
- this.action();
727
- this.isDisposed = true;
728
- }
729
- };
717
+ /** Performs the task of cleaning up resources. */
718
+ Disposable.prototype.dispose = function () {
719
+ if (!this.isDisposed) {
720
+ this.action();
721
+ this.isDisposed = true;
722
+ }
723
+ };
730
724
 
731
- /**
732
- * Creates a disposable object that invokes the specified action when disposed.
733
- * @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once.
734
- * @return {Disposable} The disposable object that runs the given action upon disposal.
735
- */
736
- var disposableCreate = Disposable.create = function (action) { return new Disposable(action); };
725
+ /**
726
+ * Creates a disposable object that invokes the specified action when disposed.
727
+ * @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once.
728
+ * @return {Disposable} The disposable object that runs the given action upon disposal.
729
+ */
730
+ var disposableCreate = Disposable.create = function (action) { return new Disposable(action); };
737
731
 
738
- /**
739
- * Gets the disposable that does nothing when disposed.
740
- */
741
- var disposableEmpty = Disposable.empty = { dispose: noop };
732
+ /**
733
+ * Gets the disposable that does nothing when disposed.
734
+ */
735
+ var disposableEmpty = Disposable.empty = { dispose: noop };
742
736
 
743
- var SingleAssignmentDisposable = Rx.SingleAssignmentDisposable =
744
- SerialDisposable = Rx.SerialDisposable = (function () {
737
+ var SingleAssignmentDisposable = Rx.SingleAssignmentDisposable = (function () {
745
738
  function BooleanDisposable () {
746
739
  this.isDisposed = false;
747
740
  this.current = null;
@@ -786,6 +779,7 @@ if (!Array.prototype.forEach) {
786
779
 
787
780
  return BooleanDisposable;
788
781
  }());
782
+ var SerialDisposable = Rx.SerialDisposable = SingleAssignmentDisposable;
789
783
  /**
790
784
  * Represents a disposable resource that only disposes its underlying disposable resource when all dependent disposable objects have been disposed.
791
785
  */
@@ -1154,6 +1148,7 @@ if (!Array.prototype.forEach) {
1154
1148
  }(Scheduler.prototype));
1155
1149
 
1156
1150
  (function (schedulerProto) {
1151
+
1157
1152
  /**
1158
1153
  * 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.
1159
1154
  * @param {Number} period Period for running the work periodically.
@@ -1171,17 +1166,19 @@ if (!Array.prototype.forEach) {
1171
1166
  * @param {Function} action Action to be executed, potentially updating the state.
1172
1167
  * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort).
1173
1168
  */
1174
- Scheduler.prototype.schedulePeriodicWithState = function (state, period, action) {
1169
+ Scheduler.prototype.schedulePeriodicWithState = function(state, period, action) {
1170
+ if (typeof root.setInterval === 'undefined') { throw new Error('Periodic scheduling not supported.'); }
1175
1171
  var s = state;
1176
-
1177
- var id = setInterval(function () {
1172
+
1173
+ var id = root.setInterval(function () {
1178
1174
  s = action(s);
1179
1175
  }, period);
1180
1176
 
1181
1177
  return disposableCreate(function () {
1182
- clearInterval(id);
1178
+ root.clearInterval(id);
1183
1179
  });
1184
1180
  };
1181
+
1185
1182
  }(Scheduler.prototype));
1186
1183
 
1187
1184
  (function (schedulerProto) {
@@ -1303,100 +1300,121 @@ if (!Array.prototype.forEach) {
1303
1300
  return currentScheduler;
1304
1301
  }());
1305
1302
 
1306
-
1307
1303
  var scheduleMethod, clearMethod = noop;
1308
- (function () {
1304
+ var localTimer = (function () {
1305
+ var localSetTimeout, localClearTimeout = noop;
1306
+ if ('WScript' in this) {
1307
+ localSetTimeout = function (fn, time) {
1308
+ WScript.Sleep(time);
1309
+ fn();
1310
+ };
1311
+ } else if (!!root.setTimeout) {
1312
+ localSetTimeout = root.setTimeout;
1313
+ localClearTimeout = root.clearTimeout;
1314
+ } else {
1315
+ throw new Error('No concurrency detected!');
1316
+ }
1309
1317
 
1310
- var reNative = RegExp('^' +
1311
- String(toString)
1312
- .replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
1313
- .replace(/toString| for [^\]]+/g, '.*?') + '$'
1314
- );
1318
+ return {
1319
+ setTimeout: localSetTimeout,
1320
+ clearTimeout: localClearTimeout
1321
+ };
1322
+ }());
1323
+ var localSetTimeout = localTimer.setTimeout,
1324
+ localClearTimeout = localTimer.clearTimeout;
1325
+
1326
+ (function () {
1327
+
1328
+ var reNative = RegExp('^' +
1329
+ String(toString)
1330
+ .replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
1331
+ .replace(/toString| for [^\]]+/g, '.*?') + '$'
1332
+ );
1333
+
1334
+ var setImmediate = typeof (setImmediate = freeGlobal && moduleExports && freeGlobal.setImmediate) == 'function' &&
1335
+ !reNative.test(setImmediate) && setImmediate,
1336
+ clearImmediate = typeof (clearImmediate = freeGlobal && moduleExports && freeGlobal.clearImmediate) == 'function' &&
1337
+ !reNative.test(clearImmediate) && clearImmediate;
1338
+
1339
+ function postMessageSupported () {
1340
+ // Ensure not in a worker
1341
+ if (!root.postMessage || root.importScripts) { return false; }
1342
+ var isAsync = false,
1343
+ oldHandler = root.onmessage;
1344
+ // Test for async
1345
+ root.onmessage = function () { isAsync = true; };
1346
+ root.postMessage('','*');
1347
+ root.onmessage = oldHandler;
1348
+
1349
+ return isAsync;
1350
+ }
1315
1351
 
1316
- var setImmediate = typeof (setImmediate = freeGlobal && moduleExports && freeGlobal.setImmediate) == 'function' &&
1317
- !reNative.test(setImmediate) && setImmediate,
1318
- clearImmediate = typeof (clearImmediate = freeGlobal && moduleExports && freeGlobal.clearImmediate) == 'function' &&
1319
- !reNative.test(clearImmediate) && clearImmediate;
1320
-
1321
- function postMessageSupported () {
1322
- // Ensure not in a worker
1323
- if (!root.postMessage || root.importScripts) { return false; }
1324
- var isAsync = false,
1325
- oldHandler = root.onmessage;
1326
- // Test for async
1327
- root.onmessage = function () { isAsync = true; };
1328
- root.postMessage('','*');
1329
- root.onmessage = oldHandler;
1330
-
1331
- return isAsync;
1352
+ // Use in order, nextTick, setImmediate, postMessage, MessageChannel, script readystatechanged, setTimeout
1353
+ if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') {
1354
+ scheduleMethod = process.nextTick;
1355
+ } else if (typeof setImmediate === 'function') {
1356
+ scheduleMethod = setImmediate;
1357
+ clearMethod = clearImmediate;
1358
+ } else if (postMessageSupported()) {
1359
+ var MSG_PREFIX = 'ms.rx.schedule' + Math.random(),
1360
+ tasks = {},
1361
+ taskId = 0;
1362
+
1363
+ function onGlobalPostMessage(event) {
1364
+ // Only if we're a match to avoid any other global events
1365
+ if (typeof event.data === 'string' && event.data.substring(0, MSG_PREFIX.length) === MSG_PREFIX) {
1366
+ var handleId = event.data.substring(MSG_PREFIX.length),
1367
+ action = tasks[handleId];
1368
+ action();
1369
+ delete tasks[handleId];
1370
+ }
1332
1371
  }
1333
1372
 
1334
- // Use in order, nextTick, setImmediate, postMessage, MessageChannel, script readystatechanged, setTimeout
1335
- if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') {
1336
- scheduleMethod = process.nextTick;
1337
- } else if (typeof setImmediate === 'function') {
1338
- scheduleMethod = setImmediate;
1339
- clearMethod = clearImmediate;
1340
- } else if (postMessageSupported()) {
1341
- var MSG_PREFIX = 'ms.rx.schedule' + Math.random(),
1342
- tasks = {},
1343
- taskId = 0;
1344
-
1345
- function onGlobalPostMessage(event) {
1346
- // Only if we're a match to avoid any other global events
1347
- if (typeof event.data === 'string' && event.data.substring(0, MSG_PREFIX.length) === MSG_PREFIX) {
1348
- var handleId = event.data.substring(MSG_PREFIX.length),
1349
- action = tasks[handleId];
1350
- action();
1351
- delete tasks[handleId];
1352
- }
1353
- }
1373
+ if (root.addEventListener) {
1374
+ root.addEventListener('message', onGlobalPostMessage, false);
1375
+ } else {
1376
+ root.attachEvent('onmessage', onGlobalPostMessage, false);
1377
+ }
1354
1378
 
1355
- if (root.addEventListener) {
1356
- root.addEventListener('message', onGlobalPostMessage, false);
1357
- } else {
1358
- root.attachEvent('onmessage', onGlobalPostMessage, false);
1359
- }
1379
+ scheduleMethod = function (action) {
1380
+ var currentId = taskId++;
1381
+ tasks[currentId] = action;
1382
+ root.postMessage(MSG_PREFIX + currentId, '*');
1383
+ };
1384
+ } else if (!!root.MessageChannel) {
1385
+ var channel = new root.MessageChannel(),
1386
+ channelTasks = {},
1387
+ channelTaskId = 0;
1388
+
1389
+ channel.port1.onmessage = function (event) {
1390
+ var id = event.data,
1391
+ action = channelTasks[id];
1392
+ action();
1393
+ delete channelTasks[id];
1394
+ };
1360
1395
 
1361
- scheduleMethod = function (action) {
1362
- var currentId = taskId++;
1363
- tasks[currentId] = action;
1364
- root.postMessage(MSG_PREFIX + currentId, '*');
1365
- };
1366
- } else if (!!root.MessageChannel) {
1367
- var channel = new root.MessageChannel(),
1368
- channelTasks = {},
1369
- channelTaskId = 0;
1370
-
1371
- channel.port1.onmessage = function (event) {
1372
- var id = event.data,
1373
- action = channelTasks[id];
1374
- action();
1375
- delete channelTasks[id];
1376
- };
1377
-
1378
- scheduleMethod = function (action) {
1379
- var id = channelTaskId++;
1380
- channelTasks[id] = action;
1381
- channel.port2.postMessage(id);
1382
- };
1383
- } else if ('document' in root && 'onreadystatechange' in root.document.createElement('script')) {
1384
-
1385
- scheduleMethod = function (action) {
1386
- var scriptElement = root.document.createElement('script');
1387
- scriptElement.onreadystatechange = function () {
1388
- action();
1389
- scriptElement.onreadystatechange = null;
1390
- scriptElement.parentNode.removeChild(scriptElement);
1391
- scriptElement = null;
1392
- };
1393
- root.document.documentElement.appendChild(scriptElement);
1396
+ scheduleMethod = function (action) {
1397
+ var id = channelTaskId++;
1398
+ channelTasks[id] = action;
1399
+ channel.port2.postMessage(id);
1400
+ };
1401
+ } else if ('document' in root && 'onreadystatechange' in root.document.createElement('script')) {
1402
+
1403
+ scheduleMethod = function (action) {
1404
+ var scriptElement = root.document.createElement('script');
1405
+ scriptElement.onreadystatechange = function () {
1406
+ action();
1407
+ scriptElement.onreadystatechange = null;
1408
+ scriptElement.parentNode.removeChild(scriptElement);
1409
+ scriptElement = null;
1394
1410
  };
1411
+ root.document.documentElement.appendChild(scriptElement);
1412
+ };
1395
1413
 
1396
- } else {
1397
- scheduleMethod = function (action) { return setTimeout(action, 0); };
1398
- clearMethod = clearTimeout;
1399
- }
1414
+ } else {
1415
+ scheduleMethod = function (action) { return localSetTimeout(action, 0); };
1416
+ clearMethod = localClearTimeout;
1417
+ }
1400
1418
  }());
1401
1419
 
1402
1420
  /**
@@ -1405,33 +1423,33 @@ if (!Array.prototype.forEach) {
1405
1423
  var timeoutScheduler = Scheduler.timeout = (function () {
1406
1424
 
1407
1425
  function scheduleNow(state, action) {
1408
- var scheduler = this,
1409
- disposable = new SingleAssignmentDisposable();
1410
- var id = scheduleMethod(function () {
1411
- if (!disposable.isDisposed) {
1412
- disposable.setDisposable(action(scheduler, state));
1413
- }
1414
- });
1415
- return new CompositeDisposable(disposable, disposableCreate(function () {
1416
- clearMethod(id);
1417
- }));
1426
+ var scheduler = this,
1427
+ disposable = new SingleAssignmentDisposable();
1428
+ var id = scheduleMethod(function () {
1429
+ if (!disposable.isDisposed) {
1430
+ disposable.setDisposable(action(scheduler, state));
1431
+ }
1432
+ });
1433
+ return new CompositeDisposable(disposable, disposableCreate(function () {
1434
+ clearMethod(id);
1435
+ }));
1418
1436
  }
1419
1437
 
1420
1438
  function scheduleRelative(state, dueTime, action) {
1421
- var scheduler = this,
1422
- dt = Scheduler.normalize(dueTime);
1423
- if (dt === 0) {
1424
- return scheduler.scheduleWithState(state, action);
1439
+ var scheduler = this,
1440
+ dt = Scheduler.normalize(dueTime);
1441
+ if (dt === 0) {
1442
+ return scheduler.scheduleWithState(state, action);
1443
+ }
1444
+ var disposable = new SingleAssignmentDisposable();
1445
+ var id = localSetTimeout(function () {
1446
+ if (!disposable.isDisposed) {
1447
+ disposable.setDisposable(action(scheduler, state));
1425
1448
  }
1426
- var disposable = new SingleAssignmentDisposable();
1427
- var id = setTimeout(function () {
1428
- if (!disposable.isDisposed) {
1429
- disposable.setDisposable(action(scheduler, state));
1430
- }
1431
- }, dt);
1432
- return new CompositeDisposable(disposable, disposableCreate(function () {
1433
- clearTimeout(id);
1434
- }));
1449
+ }, dt);
1450
+ return new CompositeDisposable(disposable, disposableCreate(function () {
1451
+ localClearTimeout(id);
1452
+ }));
1435
1453
  }
1436
1454
 
1437
1455
  function scheduleAbsolute(state, dueTime, action) {
@@ -2023,11 +2041,11 @@ if (!Array.prototype.forEach) {
2023
2041
  return CheckedObserver;
2024
2042
  }(Observer));
2025
2043
 
2026
- var ScheduledObserver = Rx.internals.ScheduledObserver = (function (_super) {
2027
- inherits(ScheduledObserver, _super);
2044
+ var ScheduledObserver = Rx.internals.ScheduledObserver = (function (__super__) {
2045
+ inherits(ScheduledObserver, __super__);
2028
2046
 
2029
2047
  function ScheduledObserver(scheduler, observer) {
2030
- _super.call(this);
2048
+ __super__.call(this);
2031
2049
  this.scheduler = scheduler;
2032
2050
  this.observer = observer;
2033
2051
  this.isAcquired = false;
@@ -2043,10 +2061,10 @@ if (!Array.prototype.forEach) {
2043
2061
  });
2044
2062
  };
2045
2063
 
2046
- ScheduledObserver.prototype.error = function (exception) {
2064
+ ScheduledObserver.prototype.error = function (err) {
2047
2065
  var self = this;
2048
2066
  this.queue.push(function () {
2049
- self.observer.onError(exception);
2067
+ self.observer.onError(err);
2050
2068
  });
2051
2069
  };
2052
2070
 
@@ -2085,42 +2103,37 @@ if (!Array.prototype.forEach) {
2085
2103
  };
2086
2104
 
2087
2105
  ScheduledObserver.prototype.dispose = function () {
2088
- _super.prototype.dispose.call(this);
2106
+ __super__.prototype.dispose.call(this);
2089
2107
  this.disposable.dispose();
2090
2108
  };
2091
2109
 
2092
2110
  return ScheduledObserver;
2093
2111
  }(AbstractObserver));
2094
2112
 
2095
- /** @private */
2096
- var ObserveOnObserver = (function (_super) {
2097
- inherits(ObserveOnObserver, _super);
2113
+ var ObserveOnObserver = (function (__super__) {
2114
+ inherits(ObserveOnObserver, __super__);
2098
2115
 
2099
- /** @private */
2100
- function ObserveOnObserver() {
2101
- _super.apply(this, arguments);
2102
- }
2116
+ function ObserveOnObserver() {
2117
+ __super__.apply(this, arguments);
2118
+ }
2103
2119
 
2104
- /** @private */
2105
- ObserveOnObserver.prototype.next = function (value) {
2106
- _super.prototype.next.call(this, value);
2107
- this.ensureActive();
2108
- };
2120
+ ObserveOnObserver.prototype.next = function (value) {
2121
+ __super__.prototype.next.call(this, value);
2122
+ this.ensureActive();
2123
+ };
2109
2124
 
2110
- /** @private */
2111
- ObserveOnObserver.prototype.error = function (e) {
2112
- _super.prototype.error.call(this, e);
2113
- this.ensureActive();
2114
- };
2125
+ ObserveOnObserver.prototype.error = function (e) {
2126
+ __super__.prototype.error.call(this, e);
2127
+ this.ensureActive();
2128
+ };
2115
2129
 
2116
- /** @private */
2117
- ObserveOnObserver.prototype.completed = function () {
2118
- _super.prototype.completed.call(this);
2119
- this.ensureActive();
2120
- };
2130
+ ObserveOnObserver.prototype.completed = function () {
2131
+ __super__.prototype.completed.call(this);
2132
+ this.ensureActive();
2133
+ };
2121
2134
 
2122
- return ObserveOnObserver;
2123
- })(ScheduledObserver);
2135
+ return ObserveOnObserver;
2136
+ })(ScheduledObserver);
2124
2137
 
2125
2138
  var observableProto;
2126
2139
 
@@ -2160,43 +2173,43 @@ if (!Array.prototype.forEach) {
2160
2173
  return Observable;
2161
2174
  })();
2162
2175
 
2163
- /**
2164
- * Wraps the source sequence in order to run its observer callbacks on the specified scheduler.
2165
- *
2166
- * This only invokes observer callbacks on a scheduler. In case the subscription and/or unsubscription actions have side-effects
2167
- * that require to be run on a scheduler, use subscribeOn.
2168
- *
2169
- * @param {Scheduler} scheduler Scheduler to notify observers on.
2170
- * @returns {Observable} The source sequence whose observations happen on the specified scheduler.
2171
- */
2172
- observableProto.observeOn = function (scheduler) {
2173
- var source = this;
2174
- return new AnonymousObservable(function (observer) {
2175
- return source.subscribe(new ObserveOnObserver(scheduler, observer));
2176
- });
2177
- };
2176
+ /**
2177
+ * Wraps the source sequence in order to run its observer callbacks on the specified scheduler.
2178
+ *
2179
+ * This only invokes observer callbacks on a scheduler. In case the subscription and/or unsubscription actions have side-effects
2180
+ * that require to be run on a scheduler, use subscribeOn.
2181
+ *
2182
+ * @param {Scheduler} scheduler Scheduler to notify observers on.
2183
+ * @returns {Observable} The source sequence whose observations happen on the specified scheduler.
2184
+ */
2185
+ observableProto.observeOn = function (scheduler) {
2186
+ var source = this;
2187
+ return new AnonymousObservable(function (observer) {
2188
+ return source.subscribe(new ObserveOnObserver(scheduler, observer));
2189
+ });
2190
+ };
2178
2191
 
2179
- /**
2180
- * Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler. This operation is not commonly used;
2181
- * see the remarks section for more information on the distinction between subscribeOn and observeOn.
2192
+ /**
2193
+ * Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler. This operation is not commonly used;
2194
+ * see the remarks section for more information on the distinction between subscribeOn and observeOn.
2182
2195
 
2183
- * This only performs the side-effects of subscription and unsubscription on the specified scheduler. In order to invoke observer
2184
- * callbacks on a scheduler, use observeOn.
2196
+ * This only performs the side-effects of subscription and unsubscription on the specified scheduler. In order to invoke observer
2197
+ * callbacks on a scheduler, use observeOn.
2185
2198
 
2186
- * @param {Scheduler} scheduler Scheduler to perform subscription and unsubscription actions on.
2187
- * @returns {Observable} The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler.
2188
- */
2189
- observableProto.subscribeOn = function (scheduler) {
2190
- var source = this;
2191
- return new AnonymousObservable(function (observer) {
2192
- var m = new SingleAssignmentDisposable(), d = new SerialDisposable();
2193
- d.setDisposable(m);
2194
- m.setDisposable(scheduler.schedule(function () {
2195
- d.setDisposable(new ScheduledDisposable(scheduler, source.subscribe(observer)));
2196
- }));
2197
- return d;
2198
- });
2199
- };
2199
+ * @param {Scheduler} scheduler Scheduler to perform subscription and unsubscription actions on.
2200
+ * @returns {Observable} The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler.
2201
+ */
2202
+ observableProto.subscribeOn = function (scheduler) {
2203
+ var source = this;
2204
+ return new AnonymousObservable(function (observer) {
2205
+ var m = new SingleAssignmentDisposable(), d = new SerialDisposable();
2206
+ d.setDisposable(m);
2207
+ m.setDisposable(scheduler.schedule(function () {
2208
+ d.setDisposable(new ScheduledDisposable(scheduler, source.subscribe(observer)));
2209
+ }));
2210
+ return d;
2211
+ });
2212
+ };
2200
2213
 
2201
2214
  /**
2202
2215
  * Converts a Promise to an Observable sequence
@@ -2219,38 +2232,32 @@ if (!Array.prototype.forEach) {
2219
2232
  return subject;
2220
2233
  });
2221
2234
  };
2222
- /*
2223
- * Converts an existing observable sequence to an ES6 Compatible Promise
2224
- * @example
2225
- * var promise = Rx.Observable.return(42).toPromise(RSVP.Promise);
2226
- *
2227
- * // With config
2228
- * Rx.config.Promise = RSVP.Promise;
2229
- * var promise = Rx.Observable.return(42).toPromise();
2230
- * @param {Function} [promiseCtor] The constructor of the promise. If not provided, it looks for it in Rx.config.Promise.
2231
- * @returns {Promise} An ES6 compatible promise with the last value from the observable sequence.
2232
- */
2233
- observableProto.toPromise = function (promiseCtor) {
2234
- promiseCtor || (promiseCtor = Rx.config.Promise);
2235
- if (!promiseCtor) {
2236
- throw new Error('Promise type not provided nor in Rx.config.Promise');
2237
- }
2238
- var source = this;
2239
- return new promiseCtor(function (resolve, reject) {
2240
- // No cancellation can be done
2241
- var value, hasValue = false;
2242
- source.subscribe(function (v) {
2243
- value = v;
2244
- hasValue = true;
2245
- }, function (err) {
2246
- reject(err);
2247
- }, function () {
2248
- if (hasValue) {
2249
- resolve(value);
2250
- }
2251
- });
2252
- });
2253
- };
2235
+ /*
2236
+ * Converts an existing observable sequence to an ES6 Compatible Promise
2237
+ * @example
2238
+ * var promise = Rx.Observable.return(42).toPromise(RSVP.Promise);
2239
+ *
2240
+ * // With config
2241
+ * Rx.config.Promise = RSVP.Promise;
2242
+ * var promise = Rx.Observable.return(42).toPromise();
2243
+ * @param {Function} [promiseCtor] The constructor of the promise. If not provided, it looks for it in Rx.config.Promise.
2244
+ * @returns {Promise} An ES6 compatible promise with the last value from the observable sequence.
2245
+ */
2246
+ observableProto.toPromise = function (promiseCtor) {
2247
+ promiseCtor || (promiseCtor = Rx.config.Promise);
2248
+ if (!promiseCtor) { throw new TypeError('Promise type not provided nor in Rx.config.Promise'); }
2249
+ var source = this;
2250
+ return new promiseCtor(function (resolve, reject) {
2251
+ // No cancellation can be done
2252
+ var value, hasValue = false;
2253
+ source.subscribe(function (v) {
2254
+ value = v;
2255
+ hasValue = true;
2256
+ }, reject, function () {
2257
+ hasValue && resolve(value);
2258
+ });
2259
+ });
2260
+ };
2254
2261
  /**
2255
2262
  * Creates a list from an observable sequence.
2256
2263
  * @returns An observable sequence containing a single element with a list containing all the elements of the source sequence.
@@ -2479,15 +2486,15 @@ if (!Array.prototype.forEach) {
2479
2486
  });
2480
2487
  };
2481
2488
 
2482
- /**
2483
- * Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins).
2484
- * @returns {Observable} An observable sequence whose observers will never get called.
2485
- */
2486
- var observableNever = Observable.never = function () {
2487
- return new AnonymousObservable(function () {
2488
- return disposableEmpty;
2489
- });
2490
- };
2489
+ /**
2490
+ * Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins).
2491
+ * @returns {Observable} An observable sequence whose observers will never get called.
2492
+ */
2493
+ var observableNever = Observable.never = function () {
2494
+ return new AnonymousObservable(function () {
2495
+ return disposableEmpty;
2496
+ });
2497
+ };
2491
2498
 
2492
2499
  /**
2493
2500
  * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.
@@ -2580,16 +2587,12 @@ if (!Array.prototype.forEach) {
2580
2587
 
2581
2588
  /**
2582
2589
  * Returns an observable sequence that terminates with an exception, using the specified scheduler to send out the single onError message.
2583
- * There is an alias to this method called 'throwException' for browsers <IE9.
2584
- *
2585
- * @example
2586
- * var res = Rx.Observable.throw(new Error('Error'));
2587
- * var res = Rx.Observable.throw(new Error('Error'), Rx.Scheduler.timeout);
2590
+ * There is an alias to this method called 'throwError' for browsers <IE9.
2588
2591
  * @param {Mixed} exception An object used for the sequence's termination.
2589
2592
  * @param {Scheduler} scheduler Scheduler to send the exceptional termination call on. If not specified, defaults to Scheduler.immediate.
2590
2593
  * @returns {Observable} The observable sequence that terminates exceptionally with the specified exception object.
2591
2594
  */
2592
- var observableThrow = Observable['throw'] = Observable.throwException = function (exception, scheduler) {
2595
+ var observableThrow = Observable['throw'] = Observable.throwException = Observable.throwError = function (exception, scheduler) {
2593
2596
  isScheduler(scheduler) || (scheduler = immediateScheduler);
2594
2597
  return new AnonymousObservable(function (observer) {
2595
2598
  return scheduler.schedule(function () {
@@ -2599,10 +2602,7 @@ if (!Array.prototype.forEach) {
2599
2602
  };
2600
2603
 
2601
2604
  /**
2602
- * Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence's lifetime.
2603
- *
2604
- * @example
2605
- * var res = Rx.Observable.using(function () { return new AsyncSubject(); }, function (s) { return s; });
2605
+ * Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence's lifetime.
2606
2606
  * @param {Function} resourceFactory Factory function to obtain a resource object.
2607
2607
  * @param {Function} observableFactory Factory function to obtain an observable sequence that depends on the obtained resource.
2608
2608
  * @returns {Observable} An observable sequence whose lifetime controls the lifetime of the dependent resource object.
@@ -2612,9 +2612,7 @@ if (!Array.prototype.forEach) {
2612
2612
  var disposable = disposableEmpty, resource, source;
2613
2613
  try {
2614
2614
  resource = resourceFactory();
2615
- if (resource) {
2616
- disposable = resource;
2617
- }
2615
+ resource && (disposable = resource);
2618
2616
  source = observableFactory(resource);
2619
2617
  } catch (exception) {
2620
2618
  return new CompositeDisposable(observableThrow(exception).subscribe(observer), disposable);
@@ -2971,20 +2969,16 @@ if (!Array.prototype.forEach) {
2971
2969
  var innerSubscription = new SingleAssignmentDisposable();
2972
2970
  group.add(innerSubscription);
2973
2971
 
2974
- // Check if Promise or Observable
2975
- if (isPromise(innerSource)) {
2976
- innerSource = observableFromPromise(innerSource);
2977
- }
2972
+ // Check for promises support
2973
+ isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
2978
2974
 
2979
- innerSubscription.setDisposable(innerSource.subscribe(function (x) {
2980
- observer.onNext(x);
2981
- }, observer.onError.bind(observer), function () {
2982
- group.remove(innerSubscription);
2983
- if (isStopped && group.length === 1) { observer.onCompleted(); }
2975
+ innerSubscription.setDisposable(innerSource.subscribe(observer.onNext.bind(observer), observer.onError.bind(observer), function () {
2976
+ group.remove(innerSubscription);
2977
+ isStopped && group.length === 1 && observer.onCompleted();
2984
2978
  }));
2985
2979
  }, observer.onError.bind(observer), function () {
2986
2980
  isStopped = true;
2987
- if (group.length === 1) { observer.onCompleted(); }
2981
+ group.length === 1 && observer.onCompleted();
2988
2982
  }));
2989
2983
  return group;
2990
2984
  });
@@ -2996,9 +2990,7 @@ if (!Array.prototype.forEach) {
2996
2990
  * @returns {Observable} An observable sequence that concatenates the first and second sequence, even if the first sequence terminates exceptionally.
2997
2991
  */
2998
2992
  observableProto.onErrorResumeNext = function (second) {
2999
- if (!second) {
3000
- throw new Error('Second observable is required');
3001
- }
2993
+ if (!second) { throw new Error('Second observable is required'); }
3002
2994
  return onErrorResumeNext([this, second]);
3003
2995
  };
3004
2996
 
@@ -3021,11 +3013,7 @@ if (!Array.prototype.forEach) {
3021
3013
  isPromise(current) && (current = observableFromPromise(current));
3022
3014
  d = new SingleAssignmentDisposable();
3023
3015
  subscription.setDisposable(d);
3024
- d.setDisposable(current.subscribe(observer.onNext.bind(observer), function () {
3025
- self();
3026
- }, function () {
3027
- self();
3028
- }));
3016
+ d.setDisposable(current.subscribe(observer.onNext.bind(observer), self, self));
3029
3017
  } else {
3030
3018
  observer.onCompleted();
3031
3019
  }
@@ -3064,52 +3052,44 @@ if (!Array.prototype.forEach) {
3064
3052
  });
3065
3053
  };
3066
3054
 
3067
- /**
3068
- * Transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
3069
- * @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.
3070
- */
3071
- observableProto['switch'] = observableProto.switchLatest = function () {
3072
- var sources = this;
3073
- return new AnonymousObservable(function (observer) {
3074
- var hasLatest = false,
3075
- innerSubscription = new SerialDisposable(),
3076
- isStopped = false,
3077
- latest = 0,
3078
- subscription = sources.subscribe(function (innerSource) {
3079
- var d = new SingleAssignmentDisposable(), id = ++latest;
3080
- hasLatest = true;
3081
- innerSubscription.setDisposable(d);
3082
-
3083
- // Check if Promise or Observable
3084
- if (isPromise(innerSource)) {
3085
- innerSource = observableFromPromise(innerSource);
3086
- }
3055
+ /**
3056
+ * Transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
3057
+ * @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.
3058
+ */
3059
+ observableProto['switch'] = observableProto.switchLatest = function () {
3060
+ var sources = this;
3061
+ return new AnonymousObservable(function (observer) {
3062
+ var hasLatest = false,
3063
+ innerSubscription = new SerialDisposable(),
3064
+ isStopped = false,
3065
+ latest = 0,
3066
+ subscription = sources.subscribe(
3067
+ function (innerSource) {
3068
+ var d = new SingleAssignmentDisposable(), id = ++latest;
3069
+ hasLatest = true;
3070
+ innerSubscription.setDisposable(d);
3071
+
3072
+ // Check if Promise or Observable
3073
+ isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
3087
3074
 
3088
- d.setDisposable(innerSource.subscribe(function (x) {
3089
- if (latest === id) {
3090
- observer.onNext(x);
3091
- }
3092
- }, function (e) {
3093
- if (latest === id) {
3094
- observer.onError(e);
3095
- }
3096
- }, function () {
3097
- if (latest === id) {
3098
- hasLatest = false;
3099
- if (isStopped) {
3100
- observer.onCompleted();
3101
- }
3102
- }
3103
- }));
3104
- }, observer.onError.bind(observer), function () {
3105
- isStopped = true;
3106
- if (!hasLatest) {
3107
- observer.onCompleted();
3108
- }
3109
- });
3110
- return new CompositeDisposable(subscription, innerSubscription);
3111
- });
3112
- };
3075
+ d.setDisposable(innerSource.subscribe(
3076
+ function (x) { latest === id && observer.onNext(x); },
3077
+ function (e) { latest === id && observer.onError(e); },
3078
+ function () {
3079
+ if (latest === id) {
3080
+ hasLatest = false;
3081
+ isStopped && observer.onCompleted();
3082
+ }
3083
+ }));
3084
+ },
3085
+ observer.onError.bind(observer),
3086
+ function () {
3087
+ isStopped = true;
3088
+ !hasLatest && observer.onCompleted();
3089
+ });
3090
+ return new CompositeDisposable(subscription, innerSubscription);
3091
+ });
3092
+ };
3113
3093
 
3114
3094
  /**
3115
3095
  * Returns the values from the source observable sequence until the other observable sequence produces a value.
@@ -3274,16 +3254,13 @@ if (!Array.prototype.forEach) {
3274
3254
  });
3275
3255
  };
3276
3256
 
3277
- /**
3278
- * Hides the identity of an observable sequence.
3279
- * @returns {Observable} An observable sequence that hides the identity of the source sequence.
3280
- */
3281
- observableProto.asObservable = function () {
3282
- var source = this;
3283
- return new AnonymousObservable(function (observer) {
3284
- return source.subscribe(observer);
3285
- });
3286
- };
3257
+ /**
3258
+ * Hides the identity of an observable sequence.
3259
+ * @returns {Observable} An observable sequence that hides the identity of the source sequence.
3260
+ */
3261
+ observableProto.asObservable = function () {
3262
+ return new AnonymousObservable(this.subscribe.bind(this));
3263
+ };
3287
3264
 
3288
3265
  /**
3289
3266
  * Projects each element of an observable sequence into zero or more buffers which are produced based on element count information.
@@ -3448,35 +3425,35 @@ if (!Array.prototype.forEach) {
3448
3425
  });
3449
3426
  };
3450
3427
 
3451
- /**
3452
- * Ignores all elements in an observable sequence leaving only the termination messages.
3453
- * @returns {Observable} An empty observable sequence that signals termination, successful or exceptional, of the source sequence.
3454
- */
3455
- observableProto.ignoreElements = function () {
3456
- var source = this;
3457
- return new AnonymousObservable(function (observer) {
3458
- return source.subscribe(noop, observer.onError.bind(observer), observer.onCompleted.bind(observer));
3459
- });
3460
- };
3428
+ /**
3429
+ * Ignores all elements in an observable sequence leaving only the termination messages.
3430
+ * @returns {Observable} An empty observable sequence that signals termination, successful or exceptional, of the source sequence.
3431
+ */
3432
+ observableProto.ignoreElements = function () {
3433
+ var source = this;
3434
+ return new AnonymousObservable(function (observer) {
3435
+ return source.subscribe(noop, observer.onError.bind(observer), observer.onCompleted.bind(observer));
3436
+ });
3437
+ };
3461
3438
 
3462
- /**
3463
- * Materializes the implicit notifications of an observable sequence as explicit notification values.
3464
- * @returns {Observable} An observable sequence containing the materialized notification values from the source sequence.
3465
- */
3466
- observableProto.materialize = function () {
3467
- var source = this;
3468
- return new AnonymousObservable(function (observer) {
3469
- return source.subscribe(function (value) {
3470
- observer.onNext(notificationCreateOnNext(value));
3471
- }, function (e) {
3472
- observer.onNext(notificationCreateOnError(e));
3473
- observer.onCompleted();
3474
- }, function () {
3475
- observer.onNext(notificationCreateOnCompleted());
3476
- observer.onCompleted();
3477
- });
3478
- });
3479
- };
3439
+ /**
3440
+ * Materializes the implicit notifications of an observable sequence as explicit notification values.
3441
+ * @returns {Observable} An observable sequence containing the materialized notification values from the source sequence.
3442
+ */
3443
+ observableProto.materialize = function () {
3444
+ var source = this;
3445
+ return new AnonymousObservable(function (observer) {
3446
+ return source.subscribe(function (value) {
3447
+ observer.onNext(notificationCreateOnNext(value));
3448
+ }, function (e) {
3449
+ observer.onNext(notificationCreateOnError(e));
3450
+ observer.onCompleted();
3451
+ }, function () {
3452
+ observer.onNext(notificationCreateOnCompleted());
3453
+ observer.onCompleted();
3454
+ });
3455
+ });
3456
+ };
3480
3457
 
3481
3458
  /**
3482
3459
  * Repeats the observable sequence a specified number of times. If the repeat count is not specified, the sequence repeats indefinitely.
@@ -3505,106 +3482,94 @@ if (!Array.prototype.forEach) {
3505
3482
  return enumerableRepeat(this, retryCount).catchException();
3506
3483
  };
3507
3484
 
3508
- /**
3509
- * Applies an accumulator function over an observable sequence and returns each intermediate result. The optional seed value is used as the initial accumulator value.
3510
- * For aggregation behavior with no intermediate results, see Observable.aggregate.
3511
- * @example
3512
- * var res = source.scan(function (acc, x) { return acc + x; });
3513
- * var res = source.scan(0, function (acc, x) { return acc + x; });
3514
- * @param {Mixed} [seed] The initial accumulator value.
3515
- * @param {Function} accumulator An accumulator function to be invoked on each element.
3516
- * @returns {Observable} An observable sequence containing the accumulated values.
3517
- */
3518
- observableProto.scan = function () {
3519
- var hasSeed = false, seed, accumulator, source = this;
3520
- if (arguments.length === 2) {
3521
- hasSeed = true;
3522
- seed = arguments[0];
3523
- accumulator = arguments[1];
3524
- } else {
3525
- accumulator = arguments[0];
3485
+ /**
3486
+ * Applies an accumulator function over an observable sequence and returns each intermediate result. The optional seed value is used as the initial accumulator value.
3487
+ * For aggregation behavior with no intermediate results, see Observable.aggregate.
3488
+ * @example
3489
+ * var res = source.scan(function (acc, x) { return acc + x; });
3490
+ * var res = source.scan(0, function (acc, x) { return acc + x; });
3491
+ * @param {Mixed} [seed] The initial accumulator value.
3492
+ * @param {Function} accumulator An accumulator function to be invoked on each element.
3493
+ * @returns {Observable} An observable sequence containing the accumulated values.
3494
+ */
3495
+ observableProto.scan = function () {
3496
+ var hasSeed = false, seed, accumulator, source = this;
3497
+ if (arguments.length === 2) {
3498
+ hasSeed = true;
3499
+ seed = arguments[0];
3500
+ accumulator = arguments[1];
3501
+ } else {
3502
+ accumulator = arguments[0];
3503
+ }
3504
+ return new AnonymousObservable(function (observer) {
3505
+ var hasAccumulation, accumulation, hasValue;
3506
+ return source.subscribe (
3507
+ function (x) {
3508
+ !hasValue && (hasValue = true);
3509
+ try {
3510
+ if (hasAccumulation) {
3511
+ accumulation = accumulator(accumulation, x);
3512
+ } else {
3513
+ accumulation = hasSeed ? accumulator(seed, x) : x;
3514
+ hasAccumulation = true;
3515
+ }
3516
+ } catch (e) {
3517
+ observer.onError(e);
3518
+ return;
3519
+ }
3520
+
3521
+ observer.onNext(accumulation);
3522
+ },
3523
+ observer.onError.bind(observer),
3524
+ function () {
3525
+ !hasValue && hasSeed && observer.onNext(seed);
3526
+ observer.onCompleted();
3526
3527
  }
3527
- return new AnonymousObservable(function (observer) {
3528
- var hasAccumulation, accumulation, hasValue;
3529
- return source.subscribe (
3530
- function (x) {
3531
- try {
3532
- if (!hasValue) {
3533
- hasValue = true;
3534
- }
3535
-
3536
- if (hasAccumulation) {
3537
- accumulation = accumulator(accumulation, x);
3538
- } else {
3539
- accumulation = hasSeed ? accumulator(seed, x) : x;
3540
- hasAccumulation = true;
3541
- }
3542
- } catch (e) {
3543
- observer.onError(e);
3544
- return;
3545
- }
3546
-
3547
- observer.onNext(accumulation);
3548
- },
3549
- observer.onError.bind(observer),
3550
- function () {
3551
- if (!hasValue && hasSeed) {
3552
- observer.onNext(seed);
3553
- }
3554
- observer.onCompleted();
3555
- }
3556
- );
3557
- });
3558
- };
3528
+ );
3529
+ });
3530
+ };
3559
3531
 
3560
- /**
3561
- * Bypasses a specified number of elements at the end of an observable sequence.
3562
- * @description
3563
- * This operator accumulates a queue with a length enough to store the first `count` elements. As more elements are
3564
- * received, elements are taken from the front of the queue and produced on the result sequence. This causes elements to be delayed.
3565
- * @param count Number of elements to bypass at the end of the source sequence.
3566
- * @returns {Observable} An observable sequence containing the source sequence elements except for the bypassed ones at the end.
3567
- */
3568
- observableProto.skipLast = function (count) {
3569
- var source = this;
3570
- return new AnonymousObservable(function (observer) {
3571
- var q = [];
3572
- return source.subscribe(function (x) {
3573
- q.push(x);
3574
- if (q.length > count) {
3575
- observer.onNext(q.shift());
3576
- }
3577
- }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
3578
- });
3579
- };
3532
+ /**
3533
+ * Bypasses a specified number of elements at the end of an observable sequence.
3534
+ * @description
3535
+ * This operator accumulates a queue with a length enough to store the first `count` elements. As more elements are
3536
+ * received, elements are taken from the front of the queue and produced on the result sequence. This causes elements to be delayed.
3537
+ * @param count Number of elements to bypass at the end of the source sequence.
3538
+ * @returns {Observable} An observable sequence containing the source sequence elements except for the bypassed ones at the end.
3539
+ */
3540
+ observableProto.skipLast = function (count) {
3541
+ var source = this;
3542
+ return new AnonymousObservable(function (observer) {
3543
+ var q = [];
3544
+ return source.subscribe(function (x) {
3545
+ q.push(x);
3546
+ q.length > count && observer.onNext(q.shift());
3547
+ }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
3548
+ });
3549
+ };
3580
3550
 
3581
- /**
3582
- * Prepends a sequence of values to an observable sequence with an optional scheduler and an argument list of values to prepend.
3583
- *
3584
- * var res = source.startWith(1, 2, 3);
3585
- * var res = source.startWith(Rx.Scheduler.timeout, 1, 2, 3);
3586
- *
3587
- * @memberOf Observable#
3588
- * @returns {Observable} The source sequence prepended with the specified values.
3589
- */
3590
- observableProto.startWith = function () {
3591
- var values, scheduler, start = 0;
3592
- if (!!arguments.length && 'now' in Object(arguments[0])) {
3593
- scheduler = arguments[0];
3594
- start = 1;
3595
- } else {
3596
- scheduler = immediateScheduler;
3597
- }
3598
- values = slice.call(arguments, start);
3599
- return enumerableFor([observableFromArray(values, scheduler), this]).concat();
3600
- };
3551
+ /**
3552
+ * Prepends a sequence of values to an observable sequence with an optional scheduler and an argument list of values to prepend.
3553
+ * @example
3554
+ * var res = source.startWith(1, 2, 3);
3555
+ * var res = source.startWith(Rx.Scheduler.timeout, 1, 2, 3);
3556
+ * @param {Arguments} args The specified values to prepend to the observable sequence
3557
+ * @returns {Observable} The source sequence prepended with the specified values.
3558
+ */
3559
+ observableProto.startWith = function () {
3560
+ var values, scheduler, start = 0;
3561
+ if (!!arguments.length && isScheduler(arguments[0])) {
3562
+ scheduler = arguments[0];
3563
+ start = 1;
3564
+ } else {
3565
+ scheduler = immediateScheduler;
3566
+ }
3567
+ values = slice.call(arguments, start);
3568
+ return enumerableFor([observableFromArray(values, scheduler), this]).concat();
3569
+ };
3601
3570
 
3602
3571
  /**
3603
3572
  * Returns a specified number of contiguous elements from the end of an observable sequence.
3604
- *
3605
- * @example
3606
- * var res = source.takeLast(5);
3607
- *
3608
3573
  * @description
3609
3574
  * This operator accumulates a buffer with a length enough to store elements count elements. Upon completion of
3610
3575
  * the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.
@@ -3906,14 +3871,14 @@ if (!Array.prototype.forEach) {
3906
3871
  });
3907
3872
  };
3908
3873
 
3909
- /**
3910
- * Retrieves the value of a specified property from all elements in the Observable sequence.
3911
- * @param {String} property The property to pluck.
3912
- * @returns {Observable} Returns a new Observable sequence of property values.
3913
- */
3914
- observableProto.pluck = function (property) {
3915
- return this.select(function (x) { return x[property]; });
3916
- };
3874
+ /**
3875
+ * Retrieves the value of a specified property from all elements in the Observable sequence.
3876
+ * @param {String} prop The property to pluck.
3877
+ * @returns {Observable} Returns a new Observable sequence of property values.
3878
+ */
3879
+ observableProto.pluck = function (prop) {
3880
+ return this.map(function (x) { return x[prop]; });
3881
+ };
3917
3882
 
3918
3883
  function flatMap(source, selector, thisArg) {
3919
3884
  return source.map(function (x, i) {
@@ -4009,133 +3974,118 @@ if (!Array.prototype.forEach) {
4009
3974
  });
4010
3975
  }).mergeAll();
4011
3976
  };
4012
- /**
4013
- * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then
4014
- * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
4015
- * @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.
4016
- * @param {Any} [thisArg] Object to use as this when executing callback.
4017
- * @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
4018
- * and that at any point in time produces the elements of the most recent inner observable sequence that has been received.
4019
- */
4020
- observableProto.selectSwitch = observableProto.flatMapLatest = observableProto.switchMap = function (selector, thisArg) {
4021
- return this.select(selector, thisArg).switchLatest();
4022
- };
3977
+ /**
3978
+ * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then
3979
+ * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
3980
+ * @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.
3981
+ * @param {Any} [thisArg] Object to use as this when executing callback.
3982
+ * @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
3983
+ * and that at any point in time produces the elements of the most recent inner observable sequence that has been received.
3984
+ */
3985
+ observableProto.selectSwitch = observableProto.flatMapLatest = observableProto.switchMap = function (selector, thisArg) {
3986
+ return this.select(selector, thisArg).switchLatest();
3987
+ };
4023
3988
 
4024
- /**
4025
- * Bypasses a specified number of elements in an observable sequence and then returns the remaining elements.
4026
- * @param {Number} count The number of elements to skip before returning the remaining elements.
4027
- * @returns {Observable} An observable sequence that contains the elements that occur after the specified index in the input sequence.
4028
- */
4029
- observableProto.skip = function (count) {
4030
- if (count < 0) {
4031
- throw new Error(argumentOutOfRange);
3989
+ /**
3990
+ * Bypasses a specified number of elements in an observable sequence and then returns the remaining elements.
3991
+ * @param {Number} count The number of elements to skip before returning the remaining elements.
3992
+ * @returns {Observable} An observable sequence that contains the elements that occur after the specified index in the input sequence.
3993
+ */
3994
+ observableProto.skip = function (count) {
3995
+ if (count < 0) { throw new Error(argumentOutOfRange); }
3996
+ var source = this;
3997
+ return new AnonymousObservable(function (observer) {
3998
+ var remaining = count;
3999
+ return source.subscribe(function (x) {
4000
+ if (remaining <= 0) {
4001
+ observer.onNext(x);
4002
+ } else {
4003
+ remaining--;
4004
+ }
4005
+ }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
4006
+ });
4007
+ };
4008
+
4009
+ /**
4010
+ * Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
4011
+ * The element's index is used in the logic of the predicate function.
4012
+ *
4013
+ * var res = source.skipWhile(function (value) { return value < 10; });
4014
+ * var res = source.skipWhile(function (value, index) { return value < 10 || index < 10; });
4015
+ * @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.
4016
+ * @param {Any} [thisArg] Object to use as this when executing callback.
4017
+ * @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.
4018
+ */
4019
+ observableProto.skipWhile = function (predicate, thisArg) {
4020
+ var source = this;
4021
+ return new AnonymousObservable(function (observer) {
4022
+ var i = 0, running = false;
4023
+ return source.subscribe(function (x) {
4024
+ if (!running) {
4025
+ try {
4026
+ running = !predicate.call(thisArg, x, i++, source);
4027
+ } catch (e) {
4028
+ observer.onError(e);
4029
+ return;
4030
+ }
4032
4031
  }
4033
- var observable = this;
4034
- return new AnonymousObservable(function (observer) {
4035
- var remaining = count;
4036
- return observable.subscribe(function (x) {
4037
- if (remaining <= 0) {
4038
- observer.onNext(x);
4039
- } else {
4040
- remaining--;
4041
- }
4042
- }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
4043
- });
4044
- };
4032
+ running && observer.onNext(x);
4033
+ }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
4034
+ });
4035
+ };
4045
4036
 
4046
- /**
4047
- * Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
4048
- * The element's index is used in the logic of the predicate function.
4049
- *
4050
- * var res = source.skipWhile(function (value) { return value < 10; });
4051
- * var res = source.skipWhile(function (value, index) { return value < 10 || index < 10; });
4052
- * @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.
4053
- * @param {Any} [thisArg] Object to use as this when executing callback.
4054
- * @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.
4055
- */
4056
- observableProto.skipWhile = function (predicate, thisArg) {
4057
- var source = this;
4058
- return new AnonymousObservable(function (observer) {
4059
- var i = 0, running = false;
4060
- return source.subscribe(function (x) {
4061
- if (!running) {
4062
- try {
4063
- running = !predicate.call(thisArg, x, i++, source);
4064
- } catch (e) {
4065
- observer.onError(e);
4066
- return;
4067
- }
4068
- }
4069
- if (running) {
4070
- observer.onNext(x);
4071
- }
4072
- }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
4073
- });
4074
- };
4037
+ /**
4038
+ * 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).
4039
+ *
4040
+ * var res = source.take(5);
4041
+ * var res = source.take(0, Rx.Scheduler.timeout);
4042
+ * @param {Number} count The number of elements to return.
4043
+ * @param {Scheduler} [scheduler] Scheduler used to produce an OnCompleted message in case <paramref name="count count</paramref> is set to 0.
4044
+ * @returns {Observable} An observable sequence that contains the specified number of elements from the start of the input sequence.
4045
+ */
4046
+ observableProto.take = function (count, scheduler) {
4047
+ if (count < 0) { throw new RangeError(argumentOutOfRange); }
4048
+ if (count === 0) { return observableEmpty(scheduler); }
4049
+ var observable = this;
4050
+ return new AnonymousObservable(function (observer) {
4051
+ var remaining = count;
4052
+ return observable.subscribe(function (x) {
4053
+ if (remaining-- > 0) {
4054
+ observer.onNext(x);
4055
+ remaining === 0 && observer.onCompleted();
4056
+ }
4057
+ }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
4058
+ });
4059
+ };
4075
4060
 
4076
- /**
4077
- * 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).
4078
- *
4079
- * var res = source.take(5);
4080
- * var res = source.take(0, Rx.Scheduler.timeout);
4081
- * @param {Number} count The number of elements to return.
4082
- * @param {Scheduler} [scheduler] Scheduler used to produce an OnCompleted message in case <paramref name="count count</paramref> is set to 0.
4083
- * @returns {Observable} An observable sequence that contains the specified number of elements from the start of the input sequence.
4084
- */
4085
- observableProto.take = function (count, scheduler) {
4086
- if (count < 0) {
4087
- throw new Error(argumentOutOfRange);
4088
- }
4089
- if (count === 0) {
4090
- return observableEmpty(scheduler);
4061
+ /**
4062
+ * Returns elements from an observable sequence as long as a specified condition is true.
4063
+ * The element's index is used in the logic of the predicate function.
4064
+ * @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.
4065
+ * @param {Any} [thisArg] Object to use as this when executing callback.
4066
+ * @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.
4067
+ */
4068
+ observableProto.takeWhile = function (predicate, thisArg) {
4069
+ var observable = this;
4070
+ return new AnonymousObservable(function (observer) {
4071
+ var i = 0, running = true;
4072
+ return observable.subscribe(function (x) {
4073
+ if (running) {
4074
+ try {
4075
+ running = predicate.call(thisArg, x, i++, observable);
4076
+ } catch (e) {
4077
+ observer.onError(e);
4078
+ return;
4079
+ }
4080
+ if (running) {
4081
+ observer.onNext(x);
4082
+ } else {
4083
+ observer.onCompleted();
4084
+ }
4091
4085
  }
4092
- var observable = this;
4093
- return new AnonymousObservable(function (observer) {
4094
- var remaining = count;
4095
- return observable.subscribe(function (x) {
4096
- if (remaining > 0) {
4097
- remaining--;
4098
- observer.onNext(x);
4099
- if (remaining === 0) {
4100
- observer.onCompleted();
4101
- }
4102
- }
4103
- }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
4104
- });
4105
- };
4106
-
4107
- /**
4108
- * Returns elements from an observable sequence as long as a specified condition is true.
4109
- * The element's index is used in the logic of the predicate function.
4110
- *
4111
- * @example
4112
- * var res = source.takeWhile(function (value) { return value < 10; });
4113
- * var res = source.takeWhile(function (value, index) { return value < 10 || index < 10; });
4114
- * @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.
4115
- * @param {Any} [thisArg] Object to use as this when executing callback.
4116
- * @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.
4117
- */
4118
- observableProto.takeWhile = function (predicate, thisArg) {
4119
- var observable = this;
4120
- return new AnonymousObservable(function (observer) {
4121
- var i = 0, running = true;
4122
- return observable.subscribe(function (x) {
4123
- if (running) {
4124
- try {
4125
- running = predicate.call(thisArg, x, i++, observable);
4126
- } catch (e) {
4127
- observer.onError(e);
4128
- return;
4129
- }
4130
- if (running) {
4131
- observer.onNext(x);
4132
- } else {
4133
- observer.onCompleted();
4134
- }
4135
- }
4136
- }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
4137
- });
4138
- };
4086
+ }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
4087
+ });
4088
+ };
4139
4089
 
4140
4090
  /**
4141
4091
  * Filters the elements of an observable sequence based on a predicate by incorporating the element's index.