rxjs-rails 2.4.1 → 2.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rxjs/rails/version.rb +1 -1
  3. data/vendor/assets/javascripts/rx.aggregates.js +15 -19
  4. data/vendor/assets/javascripts/rx.aggregates.map +1 -1
  5. data/vendor/assets/javascripts/rx.aggregates.min.js +1 -1
  6. data/vendor/assets/javascripts/rx.all.compat.js +1014 -566
  7. data/vendor/assets/javascripts/rx.all.compat.map +1 -1
  8. data/vendor/assets/javascripts/rx.all.compat.min.js +4 -4
  9. data/vendor/assets/javascripts/rx.all.js +1009 -563
  10. data/vendor/assets/javascripts/rx.all.map +1 -1
  11. data/vendor/assets/javascripts/rx.all.min.js +4 -4
  12. data/vendor/assets/javascripts/rx.async.compat.js +17 -15
  13. data/vendor/assets/javascripts/rx.async.compat.map +1 -1
  14. data/vendor/assets/javascripts/rx.async.compat.min.js +1 -1
  15. data/vendor/assets/javascripts/rx.async.js +17 -15
  16. data/vendor/assets/javascripts/rx.async.map +1 -1
  17. data/vendor/assets/javascripts/rx.async.min.js +1 -1
  18. data/vendor/assets/javascripts/rx.backpressure.js +53 -43
  19. data/vendor/assets/javascripts/rx.backpressure.map +1 -1
  20. data/vendor/assets/javascripts/rx.backpressure.min.js +1 -1
  21. data/vendor/assets/javascripts/rx.binding.js +31 -12
  22. data/vendor/assets/javascripts/rx.binding.map +1 -1
  23. data/vendor/assets/javascripts/rx.binding.min.js +1 -1
  24. data/vendor/assets/javascripts/rx.coincidence.js +3 -2
  25. data/vendor/assets/javascripts/rx.coincidence.map +1 -1
  26. data/vendor/assets/javascripts/rx.coincidence.min.js +1 -1
  27. data/vendor/assets/javascripts/rx.compat.js +821 -444
  28. data/vendor/assets/javascripts/rx.compat.map +1 -1
  29. data/vendor/assets/javascripts/rx.compat.min.js +2 -2
  30. data/vendor/assets/javascripts/rx.experimental.js +2 -9
  31. data/vendor/assets/javascripts/rx.experimental.map +1 -1
  32. data/vendor/assets/javascripts/rx.experimental.min.js +1 -1
  33. data/vendor/assets/javascripts/rx.joinpatterns.js +14 -22
  34. data/vendor/assets/javascripts/rx.joinpatterns.map +1 -1
  35. data/vendor/assets/javascripts/rx.joinpatterns.min.js +1 -1
  36. data/vendor/assets/javascripts/rx.js +817 -442
  37. data/vendor/assets/javascripts/rx.lite.compat.js +897 -443
  38. data/vendor/assets/javascripts/rx.lite.compat.map +1 -1
  39. data/vendor/assets/javascripts/rx.lite.compat.min.js +3 -2
  40. data/vendor/assets/javascripts/rx.lite.extras.compat.js +621 -0
  41. data/vendor/assets/javascripts/rx.lite.extras.compat.map +1 -0
  42. data/vendor/assets/javascripts/rx.lite.extras.compat.min.js +3 -0
  43. data/vendor/assets/javascripts/rx.lite.extras.js +53 -76
  44. data/vendor/assets/javascripts/rx.lite.extras.map +1 -1
  45. data/vendor/assets/javascripts/rx.lite.extras.min.js +1 -1
  46. data/vendor/assets/javascripts/rx.lite.js +898 -444
  47. data/vendor/assets/javascripts/rx.lite.map +1 -1
  48. data/vendor/assets/javascripts/rx.lite.min.js +3 -2
  49. data/vendor/assets/javascripts/rx.map +1 -1
  50. data/vendor/assets/javascripts/rx.min.js +2 -2
  51. data/vendor/assets/javascripts/rx.testing.js +10 -11
  52. data/vendor/assets/javascripts/rx.testing.map +1 -1
  53. data/vendor/assets/javascripts/rx.testing.min.js +1 -1
  54. data/vendor/assets/javascripts/rx.time.js +80 -40
  55. data/vendor/assets/javascripts/rx.time.map +1 -1
  56. data/vendor/assets/javascripts/rx.time.min.js +1 -1
  57. data/vendor/assets/javascripts/rx.virtualtime.js +6 -13
  58. data/vendor/assets/javascripts/rx.virtualtime.map +1 -1
  59. data/vendor/assets/javascripts/rx.virtualtime.min.js +1 -1
  60. metadata +6 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a5721386c498fb7ea75f9ab6df1999d87bafa636
4
- data.tar.gz: 63bb948c7217133244f6c860a9f2072d3824d1fd
3
+ metadata.gz: 5d08d45804c21b4feb931f66f70e3586b21c142a
4
+ data.tar.gz: 995172c50cb0292a6585558de83ba45068ff22b4
5
5
  SHA512:
6
- metadata.gz: 246d9d2d18f1838c822f1edb231346143828d6255d66c96d9ff09554cbdb7bce973c700fc3e1fb74cec2c98dfb0cade1af014fcc0f5257a99230531a658d3eca
7
- data.tar.gz: 0964d5d0a309e618951c84fe2470c8cebbbf5ef00694e6432fea4c4fb189e818fe838e6ef33fd6a8b8dd64d68f80a1dcdec9092a8105090851efffaec9304de1
6
+ metadata.gz: 68b4fbaf99f844f0ec6be9bfbf0572d7010dd142927cecf881d27e3c1e3e6ed5a5734daf18eacccbcc7030c2295279ada28364197e81593b7558d33788b97190
7
+ data.tar.gz: a6c37bb753be3e51aaf9c71215e80414771ac1e4e188c27515efe6cba5b57c593285f0fc81c95387043496a451af2db1c31634e5a20e8b6951e4f020d739ef40
@@ -1,6 +1,6 @@
1
1
  module Rxjs
2
2
  module Rails
3
- VERSION = "2.4.1"
3
+ VERSION = "2.5.2"
4
4
  end
5
5
  end
6
6
 
@@ -50,11 +50,9 @@
50
50
  isIterable = helpers.isIterable,
51
51
  observableFromPromise = Observable.fromPromise,
52
52
  observableFrom = Observable.from,
53
- bindCallback = Rx.internals.bindCallback;
54
-
55
- // Defaults
56
- var argumentOutOfRange = 'Argument out of range',
57
- sequenceContainsNoElements = "Sequence contains no elements.";
53
+ bindCallback = Rx.internals.bindCallback,
54
+ EmptyError = Rx.EmptyError,
55
+ ArgumentOutOfRangeError = Rx.ArgumentOutOfRangeError;
58
56
 
59
57
  function extremaBy(source, keySelector, comparer) {
60
58
  return new AnonymousObservable(function (o) {
@@ -92,7 +90,7 @@
92
90
  }
93
91
 
94
92
  function firstOnly(x) {
95
- if (x.length === 0) { throw new Error(sequenceContainsNoElements); }
93
+ if (x.length === 0) { throw new EmptyError(); }
96
94
  return x[0];
97
95
  }
98
96
 
@@ -105,7 +103,6 @@
105
103
  * @returns {Observable} An observable sequence containing a single element with the final accumulator value.
106
104
  */
107
105
  observableProto.aggregate = function () {
108
- //deprecate('aggregate', 'reduce');
109
106
  var hasSeed = false, accumulator, seed, source = this;
110
107
  if (arguments.length === 2) {
111
108
  hasSeed = true;
@@ -127,15 +124,14 @@
127
124
  hasAccumulation = true;
128
125
  }
129
126
  } catch (e) {
130
- o.onError(e);
131
- return;
127
+ return o.onError(e);
132
128
  }
133
129
  },
134
130
  function (e) { o.onError(e); },
135
131
  function () {
136
132
  hasValue && o.onNext(accumulation);
137
133
  !hasValue && hasSeed && o.onNext(seed);
138
- !hasValue && !hasSeed && o.onError(new Error(sequenceContainsNoElements));
134
+ !hasValue && !hasSeed && o.onError(new EmptyError());
139
135
  o.onCompleted();
140
136
  }
141
137
  );
@@ -168,15 +164,14 @@
168
164
  hasAccumulation = true;
169
165
  }
170
166
  } catch (e) {
171
- o.onError(e);
172
- return;
167
+ return o.onError(e);
173
168
  }
174
169
  },
175
170
  function (e) { o.onError(e); },
176
171
  function () {
177
172
  hasValue && o.onNext(accumulation);
178
173
  !hasValue && hasSeed && o.onNext(seed);
179
- !hasValue && !hasSeed && o.onError(new Error(sequenceContainsNoElements));
174
+ !hasValue && !hasSeed && o.onError(new EmptyError());
180
175
  o.onCompleted();
181
176
  }
182
177
  );
@@ -274,6 +269,7 @@
274
269
  //deprecate('contains', 'includes');
275
270
  observableProto.includes(searchElement, fromIndex);
276
271
  };
272
+
277
273
  /**
278
274
  * Returns an observable sequence containing a value that represents how many elements in the specified observable sequence satisfy a condition if provided, else the count of items.
279
275
  * @example
@@ -400,7 +396,7 @@
400
396
  count: prev.count + 1
401
397
  };
402
398
  }, {sum: 0, count: 0 }).map(function (s) {
403
- if (s.count === 0) { throw new Error(sequenceContainsNoElements); }
399
+ if (s.count === 0) { throw new EmptyError(); }
404
400
  return s.sum / s.count;
405
401
  });
406
402
  };
@@ -494,7 +490,7 @@
494
490
  };
495
491
 
496
492
  function elementAtOrDefault(source, index, hasDefault, defaultValue) {
497
- if (index < 0) { throw new Error(argumentOutOfRange); }
493
+ if (index < 0) { throw new ArgumentOutOfRangeError(); }
498
494
  return new AnonymousObservable(function (o) {
499
495
  var i = index;
500
496
  return source.subscribe(function (x) {
@@ -504,7 +500,7 @@
504
500
  }
505
501
  }, function (e) { o.onError(e); }, function () {
506
502
  if (!hasDefault) {
507
- o.onError(new Error(argumentOutOfRange));
503
+ o.onError(new ArgumentOutOfRangeError());
508
504
  } else {
509
505
  o.onNext(defaultValue);
510
506
  o.onCompleted();
@@ -549,7 +545,7 @@
549
545
  }
550
546
  }, function (e) { o.onError(e); }, function () {
551
547
  if (!seenValue && !hasDefault) {
552
- o.onError(new Error(sequenceContainsNoElements));
548
+ o.onError(new EmptyError());
553
549
  } else {
554
550
  o.onNext(value);
555
551
  o.onCompleted();
@@ -596,7 +592,7 @@
596
592
  o.onCompleted();
597
593
  }, function (e) { o.onError(e); }, function () {
598
594
  if (!hasDefault) {
599
- o.onError(new Error(sequenceContainsNoElements));
595
+ o.onError(new EmptyError());
600
596
  } else {
601
597
  o.onNext(defaultValue);
602
598
  o.onCompleted();
@@ -641,7 +637,7 @@
641
637
  seenValue = true;
642
638
  }, function (e) { o.onError(e); }, function () {
643
639
  if (!seenValue && !hasDefault) {
644
- o.onError(new Error(sequenceContainsNoElements));
640
+ o.onError(new EmptyError());
645
641
  } else {
646
642
  o.onNext(value);
647
643
  o.onCompleted();
@@ -1 +1 @@
1
- {"version":3,"file":"rx.aggregates.min.js","sources":["rx.aggregates.js"],"names":["factory","objectTypes","boolean","function","object","number","string","undefined","root","window","this","freeExports","exports","nodeType","freeModule","module","freeGlobal","global","define","amd","Rx","require","call","exp","extremaBy","source","keySelector","comparer","AnonymousObservable","o","hasValue","lastKey","list","subscribe","x","comparison","key","ex","onError","ex1","push","e","onNext","onCompleted","firstOnly","length","Error","sequenceContainsNoElements","elementAtOrDefault","index","hasDefault","defaultValue","argumentOutOfRange","i","singleOrDefaultAsync","value","seenValue","firstOrDefaultAsync","lastOrDefaultAsync","findValue","predicate","thisArg","yieldIndex","callback","bindCallback","shouldRun","Observable","observableProto","prototype","CompositeDisposable","disposableEmpty","Disposable","empty","helpers","internals","isEqual","not","defaultComparer","identity","defaultSubComparer","isFunction","isPromise","isArrayLike","isIterable","observableFromPromise","fromPromise","observableFrom","from","aggregate","accumulator","seed","hasSeed","arguments","hasAccumulation","accumulation","reduce","some","filter","observer","any","apply","isEmpty","map","every","v","all","includes","searchElement","fromIndex","a","b","isNaN","n","Infinity","Math","abs","contains","count","indexOf","sum","prev","curr","minBy","y","min","maxBy","max","average","cur","s","sequenceEqual","second","first","donel","doner","ql","qr","subscription1","equal","shift","subscription2","exception","elementAt","single","where","singleOrDefault","firstOrDefault","last","lastOrDefault","find","findIndex","toSet","Set","TypeError","add","toMap","elementSelector","Map","m","element","set"],"mappings":";CAEE,SAAUA,GACR,GAAIC,IACAC,WAAW,EACXC,YAAY,EACZC,QAAU,EACVC,QAAU,EACVC,QAAU,EACVC,WAAa,GAGbC,EAAQP,QAAmBQ,UAAWA,QAAWC,KACjDC,EAAcV,QAAmBW,WAAYA,UAAYA,QAAQC,UAAYD,QAC7EE,EAAab,QAAmBc,UAAWA,SAAWA,OAAOF,UAAYE,OAEzEC,GADgBF,GAAcA,EAAWF,UAAYD,GAAeA,EACvDV,QAAmBgB,UAAWA,SAE3CD,GAAeA,EAAWC,SAAWD,GAAcA,EAAWP,SAAWO,IACzER,EAAOQ,GAIW,kBAAXE,SAAyBA,OAAOC,IACvCD,QAAQ,MAAO,SAAUE,EAAIR,GACzB,MAAOZ,GAAQQ,EAAMI,EAASQ,KAET,gBAAXL,SAAuBA,QAAUA,OAAOH,UAAYD,EAClEI,OAAOH,QAAUZ,EAAQQ,EAAMO,OAAOH,QAASS,QAAQ,SAEvDb,EAAKY,GAAKpB,EAAQQ,KAAUA,EAAKY,MAEvCE,KAAKZ,KAAM,SAAUF,EAAMe,EAAKH,EAAIb,GA0BpC,QAASiB,GAAUC,EAAQC,EAAaC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AAI,GAAItJ,GAAKqJ,GACjB,OAAOpI,GAAOQ,UACZ,SAAUC,GACR,GAAIE,EACJ,KACEA,EAAMV,EAAYQ,GAClB,MAAOO,GAEP,WADAZ,GAAES,QAAQG,GAIZ,GAAIsH,GAAU7H,CACd,IAAI0H,EACF,IACEG,EAAUH,EAAgB1H,GAC1B,MAAOO,GAEP,WADAZ,GAAES,QAAQG,GAKdqH,EAAEE,IAAI5H,EAAK2H,IAEb,SAAUtH,GAAKZ,EAAES,QAAQG,IACzB,WACEZ,EAAEa,OAAOoH,GACTjI,EAAEc,iBAELlB,IAGIL"}
1
+ {"version":3,"file":"rx.aggregates.min.js","sources":["rx.aggregates.js"],"names":["factory","objectTypes","boolean","function","object","number","string","undefined","root","window","this","freeExports","exports","nodeType","freeModule","module","freeGlobal","global","define","amd","Rx","require","call","exp","extremaBy","source","keySelector","comparer","AnonymousObservable","o","hasValue","lastKey","list","subscribe","x","comparison","key","ex","onError","ex1","push","e","onNext","onCompleted","firstOnly","length","EmptyError","elementAtOrDefault","index","hasDefault","defaultValue","ArgumentOutOfRangeError","i","singleOrDefaultAsync","value","seenValue","Error","firstOrDefaultAsync","lastOrDefaultAsync","findValue","predicate","thisArg","yieldIndex","callback","bindCallback","shouldRun","Observable","observableProto","prototype","CompositeDisposable","disposableEmpty","Disposable","empty","helpers","internals","isEqual","not","defaultComparer","identity","defaultSubComparer","isFunction","isPromise","isArrayLike","isIterable","observableFromPromise","fromPromise","observableFrom","from","aggregate","accumulator","seed","hasSeed","arguments","hasAccumulation","accumulation","reduce","some","filter","observer","any","apply","isEmpty","map","every","v","all","includes","searchElement","fromIndex","a","b","isNaN","n","Infinity","Math","abs","contains","count","indexOf","sum","prev","curr","minBy","y","min","maxBy","max","average","cur","s","sequenceEqual","second","first","donel","doner","ql","qr","subscription1","equal","shift","subscription2","exception","elementAt","single","where","singleOrDefault","firstOrDefault","last","lastOrDefault","find","findIndex","toSet","Set","TypeError","add","toMap","elementSelector","Map","m","element","set"],"m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,EAAmBhD,MAAM,EAAMwC,IAkCnCiB,EAAgBkF,KAAO,SAAUzF,EAAWC,GAC1C,MAAOF,GAAUjD,KAAMkD,EAAWC,GAAS,IAU7CM,EAAgBmF,UAAY,SAAU1F,EAAWC,GAC/C,MAAOF,GAAUjD,KAAMkD,EAAWC,GAAS,IAO7CM,EAAgBoF,MAAQ,WACtB,GAAwB,mBAAb/I,GAAKgJ,IAAuB,KAAM,IAAIC,UACjD,IAAIhI,GAASf,IACb,OAAO,IAAIkB,GAAoB,SAAUC,GACvC,GAAIoG,GAAI,GAAIzH,GAAKgJ,GACjB,OAAO/H,GAAOQ,UACZ,SAAUC,GAAK+F,EAAEyB,IAAIxH,IACrB,SAAUO,GAAKZ,EAAES,QAAQG,IACzB,WACEZ,EAAEa,OAAOuF,GACTpG,EAAEc,iBAELlB,IASL0C,EAAgBwF,MAAQ,SAAUjI,EAAakI,GAC7C,GAAwB,mBAAbpJ,GAAKqJ,IAAuB,KAAM,IAAIJ,UACjD,IAAIhI,GAASf,IACb,OAAO,IAAIkB,GAAoB,SAAUC,GACvC,GAAIiI,GAAI,GAAItJ,GAAKqJ,GACjB,OAAOpI,GAAOQ,UACZ,SAAUC,GACR,GAAIE,EACJ,KACEA,EAAMV,EAAYQ,GAClB,MAAOO,GAEP,WADAZ,GAAES,QAAQG,GAIZ,GAAIsH,GAAU7H,CACd,IAAI0H,EACF,IACEG,EAAUH,EAAgB1H,GAC1B,MAAOO,GAEP,WADAZ,GAAES,QAAQG,GAKdqH,EAAEE,IAAI5H,EAAK2H,IAEb,SAAUtH,GAAKZ,EAAES,QAAQG,IACzB,WACEZ,EAAEa,OAAOoH,GACTjI,EAAEc,iBAELlB,IAGIL"}
@@ -1,3 +1,3 @@
1
1
  /* Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.*/
2
- (function(a){var b={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},c=b[typeof window]&&window||this,d=b[typeof exports]&&exports&&!exports.nodeType&&exports,e=b[typeof module]&&module&&!module.nodeType&&module,f=(e&&e.exports===d&&d,b[typeof global]&&global);!f||f.global!==f&&f.window!==f||(c=f),"function"==typeof define&&define.amd?define(["rx"],function(b,d){return a(c,d,b)}):"object"==typeof module&&module&&module.exports===d?module.exports=a(c,module.exports,require("./rx")):c.Rx=a(c,{},c.Rx)}).call(this,function(a,b,c,d){function e(a,b,c){return new o(function(d){var e=!1,f=null,g=[];return a.subscribe(function(a){var h,i;try{i=b(a)}catch(j){return void d.onError(j)}if(h=0,e)try{h=c(i,f)}catch(k){return void d.onError(k)}else e=!0,f=i;h>0&&(f=i,g=[]),h>=0&&g.push(a)},function(a){d.onError(a)},function(){d.onNext(g),d.onCompleted()})},a)}function f(a){if(0===a.length)throw new Error(D);return a[0]}function g(a,b,c,d){if(0>b)throw new Error(C);return new o(function(e){var f=b;return a.subscribe(function(a){0===f--&&(e.onNext(a),e.onCompleted())},function(a){e.onError(a)},function(){c?(e.onNext(d),e.onCompleted()):e.onError(new Error(C))})},a)}function h(a,b,c){return new o(function(d){var e=c,f=!1;return a.subscribe(function(a){f?d.onError(new Error("Sequence contains more than one element")):(e=a,f=!0)},function(a){d.onError(a)},function(){f||b?(d.onNext(e),d.onCompleted()):d.onError(new Error(D))})},a)}function i(a,b,c){return new o(function(d){return a.subscribe(function(a){d.onNext(a),d.onCompleted()},function(a){d.onError(a)},function(){b?(d.onNext(c),d.onCompleted()):d.onError(new Error(D))})},a)}function j(a,b,c){return new o(function(d){var e=c,f=!1;return a.subscribe(function(a){e=a,f=!0},function(a){d.onError(a)},function(){f||b?(d.onNext(e),d.onCompleted()):d.onError(new Error(D))})},a)}function k(a,b,c,e){var f=B(b,c,3);return new o(function(b){var c=0;return a.subscribe(function(d){var g;try{g=f(d,c,a)}catch(h){return void b.onError(h)}g?(b.onNext(e?c:d),b.onCompleted()):c++},function(a){b.onError(a)},function(){b.onNext(e?-1:d),b.onCompleted()})},a)}var l=c.Observable,m=l.prototype,n=c.CompositeDisposable,o=c.AnonymousObservable,p=c.Disposable.empty,q=(c.internals.isEqual,c.helpers),r=q.not,s=q.defaultComparer,t=q.identity,u=q.defaultSubComparer,v=q.isFunction,w=q.isPromise,x=q.isArrayLike,y=q.isIterable,z=l.fromPromise,A=l.from,B=c.internals.bindCallback,C="Argument out of range",D="Sequence contains no elements.";return m.aggregate=function(){var a,b,c=!1,d=this;return 2===arguments.length?(c=!0,b=arguments[0],a=arguments[1]):a=arguments[0],new o(function(e){var f,g,h;return d.subscribe(function(d){!h&&(h=!0);try{f?g=a(g,d):(g=c?a(b,d):d,f=!0)}catch(i){return void e.onError(i)}},function(a){e.onError(a)},function(){h&&e.onNext(g),!h&&c&&e.onNext(b),!h&&!c&&e.onError(new Error(D)),e.onCompleted()})},d)},m.reduce=function(a){var b,c=!1,d=this;return 2===arguments.length&&(c=!0,b=arguments[1]),new o(function(e){var f,g,h;return d.subscribe(function(d){!h&&(h=!0);try{f?g=a(g,d):(g=c?a(b,d):d,f=!0)}catch(i){return void e.onError(i)}},function(a){e.onError(a)},function(){h&&e.onNext(g),!h&&c&&e.onNext(b),!h&&!c&&e.onError(new Error(D)),e.onCompleted()})},d)},m.some=function(a,b){var c=this;return a?c.filter(a,b).some():new o(function(a){return c.subscribe(function(){a.onNext(!0),a.onCompleted()},function(b){a.onError(b)},function(){a.onNext(!1),a.onCompleted()})},c)},m.any=function(){return this.some.apply(this,arguments)},m.isEmpty=function(){return this.any().map(r)},m.every=function(a,b){return this.filter(function(b){return!a(b)},b).some().map(r)},m.all=function(){return this.every.apply(this,arguments)},m.includes=function(a,b){function c(a,b){return 0===a&&0===b||a===b||isNaN(a)&&isNaN(b)}var d=this;return new o(function(e){var f=0,g=+b||0;return 1/0===Math.abs(g)&&(g=0),0>g?(e.onNext(!1),e.onCompleted(),p):d.subscribe(function(b){f++>=g&&c(b,a)&&(e.onNext(!0),e.onCompleted())},function(a){e.onError(a)},function(){e.onNext(!1),e.onCompleted()})},this)},m.contains=function(a,b){m.includes(a,b)},m.count=function(a,b){return a?this.filter(a,b).count():this.reduce(function(a){return a+1},0)},m.indexOf=function(a,b){var c=this;return new o(function(d){var e=0,f=+b||0;return 1/0===Math.abs(f)&&(f=0),0>f?(d.onNext(-1),d.onCompleted(),p):c.subscribe(function(b){e>=f&&b===a&&(d.onNext(e),d.onCompleted()),e++},function(a){d.onError(a)},function(){d.onNext(-1),d.onCompleted()})},c)},m.sum=function(a,b){return a&&v(a)?this.map(a,b).sum():this.reduce(function(a,b){return a+b},0)},m.minBy=function(a,b){return b||(b=u),e(this,a,function(a,c){return-1*b(a,c)})},m.min=function(a){return this.minBy(t,a).map(function(a){return f(a)})},m.maxBy=function(a,b){return b||(b=u),e(this,a,b)},m.max=function(a){return this.maxBy(t,a).map(function(a){return f(a)})},m.average=function(a,b){return a&&v(a)?this.map(a,b).average():this.reduce(function(a,b){return{sum:a.sum+b,count:a.count+1}},{sum:0,count:0}).map(function(a){if(0===a.count)throw new Error(D);return a.sum/a.count})},m.sequenceEqual=function(a,b){var c=this;return b||(b=s),new o(function(d){var e=!1,f=!1,g=[],h=[],i=c.subscribe(function(a){var c,e;if(h.length>0){e=h.shift();try{c=b(e,a)}catch(i){return void d.onError(i)}c||(d.onNext(!1),d.onCompleted())}else f?(d.onNext(!1),d.onCompleted()):g.push(a)},function(a){d.onError(a)},function(){e=!0,0===g.length&&(h.length>0?(d.onNext(!1),d.onCompleted()):f&&(d.onNext(!0),d.onCompleted()))});(x(a)||y(a))&&(a=A(a)),w(a)&&(a=z(a));var j=a.subscribe(function(a){var c;if(g.length>0){var f=g.shift();try{c=b(f,a)}catch(i){return void d.onError(i)}c||(d.onNext(!1),d.onCompleted())}else e?(d.onNext(!1),d.onCompleted()):h.push(a)},function(a){d.onError(a)},function(){f=!0,0===h.length&&(g.length>0?(d.onNext(!1),d.onCompleted()):e&&(d.onNext(!0),d.onCompleted()))});return new n(i,j)},c)},m.elementAt=function(a){return g(this,a,!1)},m.elementAtOrDefault=function(a,b){return g(this,a,!0,b)},m.single=function(a,b){return a&&v(a)?this.where(a,b).single():h(this,!1)},m.singleOrDefault=function(a,b,c){return a&&v(a)?this.filter(a,c).singleOrDefault(null,b):h(this,!0,b)},m.first=function(a,b){return a?this.where(a,b).first():i(this,!1)},m.firstOrDefault=function(a,b){return a?this.where(a).firstOrDefault(null,b):i(this,!0,b)},m.last=function(a,b){return a?this.where(a,b).last():j(this,!1)},m.lastOrDefault=function(a,b,c){return a?this.where(a,c).lastOrDefault(null,b):j(this,!0,b)},m.find=function(a,b){return k(this,a,b,!1)},m.findIndex=function(a,b){return k(this,a,b,!0)},m.toSet=function(){if("undefined"==typeof a.Set)throw new TypeError;var b=this;return new o(function(c){var d=new a.Set;return b.subscribe(function(a){d.add(a)},function(a){c.onError(a)},function(){c.onNext(d),c.onCompleted()})},b)},m.toMap=function(b,c){if("undefined"==typeof a.Map)throw new TypeError;var d=this;return new o(function(e){var f=new a.Map;return d.subscribe(function(a){var d;try{d=b(a)}catch(g){return void e.onError(g)}var h=a;if(c)try{h=c(a)}catch(g){return void e.onError(g)}f.set(d,h)},function(a){e.onError(a)},function(){e.onNext(f),e.onCompleted()})},d)},c});
2
+ (function(a){var b={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},c=b[typeof window]&&window||this,d=b[typeof exports]&&exports&&!exports.nodeType&&exports,e=b[typeof module]&&module&&!module.nodeType&&module,f=(e&&e.exports===d&&d,b[typeof global]&&global);!f||f.global!==f&&f.window!==f||(c=f),"function"==typeof define&&define.amd?define(["rx"],function(b,d){return a(c,d,b)}):"object"==typeof module&&module&&module.exports===d?module.exports=a(c,module.exports,require("./rx")):c.Rx=a(c,{},c.Rx)}).call(this,function(a,b,c,d){function e(a,b,c){return new o(function(d){var e=!1,f=null,g=[];return a.subscribe(function(a){var h,i;try{i=b(a)}catch(j){return void d.onError(j)}if(h=0,e)try{h=c(i,f)}catch(k){return void d.onError(k)}else e=!0,f=i;h>0&&(f=i,g=[]),h>=0&&g.push(a)},function(a){d.onError(a)},function(){d.onNext(g),d.onCompleted()})},a)}function f(a){if(0===a.length)throw new C;return a[0]}function g(a,b,c,d){if(0>b)throw new D;return new o(function(e){var f=b;return a.subscribe(function(a){0===f--&&(e.onNext(a),e.onCompleted())},function(a){e.onError(a)},function(){c?(e.onNext(d),e.onCompleted()):e.onError(new D)})},a)}function h(a,b,c){return new o(function(d){var e=c,f=!1;return a.subscribe(function(a){f?d.onError(new Error("Sequence contains more than one element")):(e=a,f=!0)},function(a){d.onError(a)},function(){f||b?(d.onNext(e),d.onCompleted()):d.onError(new C)})},a)}function i(a,b,c){return new o(function(d){return a.subscribe(function(a){d.onNext(a),d.onCompleted()},function(a){d.onError(a)},function(){b?(d.onNext(c),d.onCompleted()):d.onError(new C)})},a)}function j(a,b,c){return new o(function(d){var e=c,f=!1;return a.subscribe(function(a){e=a,f=!0},function(a){d.onError(a)},function(){f||b?(d.onNext(e),d.onCompleted()):d.onError(new C)})},a)}function k(a,b,c,e){var f=B(b,c,3);return new o(function(b){var c=0;return a.subscribe(function(d){var g;try{g=f(d,c,a)}catch(h){return void b.onError(h)}g?(b.onNext(e?c:d),b.onCompleted()):c++},function(a){b.onError(a)},function(){b.onNext(e?-1:d),b.onCompleted()})},a)}var l=c.Observable,m=l.prototype,n=c.CompositeDisposable,o=c.AnonymousObservable,p=c.Disposable.empty,q=(c.internals.isEqual,c.helpers),r=q.not,s=q.defaultComparer,t=q.identity,u=q.defaultSubComparer,v=q.isFunction,w=q.isPromise,x=q.isArrayLike,y=q.isIterable,z=l.fromPromise,A=l.from,B=c.internals.bindCallback,C=c.EmptyError,D=c.ArgumentOutOfRangeError;return m.aggregate=function(){var a,b,c=!1,d=this;return 2===arguments.length?(c=!0,b=arguments[0],a=arguments[1]):a=arguments[0],new o(function(e){var f,g,h;return d.subscribe(function(d){!h&&(h=!0);try{f?g=a(g,d):(g=c?a(b,d):d,f=!0)}catch(i){return e.onError(i)}},function(a){e.onError(a)},function(){h&&e.onNext(g),!h&&c&&e.onNext(b),!h&&!c&&e.onError(new C),e.onCompleted()})},d)},m.reduce=function(a){var b,c=!1,d=this;return 2===arguments.length&&(c=!0,b=arguments[1]),new o(function(e){var f,g,h;return d.subscribe(function(d){!h&&(h=!0);try{f?g=a(g,d):(g=c?a(b,d):d,f=!0)}catch(i){return e.onError(i)}},function(a){e.onError(a)},function(){h&&e.onNext(g),!h&&c&&e.onNext(b),!h&&!c&&e.onError(new C),e.onCompleted()})},d)},m.some=function(a,b){var c=this;return a?c.filter(a,b).some():new o(function(a){return c.subscribe(function(){a.onNext(!0),a.onCompleted()},function(b){a.onError(b)},function(){a.onNext(!1),a.onCompleted()})},c)},m.any=function(){return this.some.apply(this,arguments)},m.isEmpty=function(){return this.any().map(r)},m.every=function(a,b){return this.filter(function(b){return!a(b)},b).some().map(r)},m.all=function(){return this.every.apply(this,arguments)},m.includes=function(a,b){function c(a,b){return 0===a&&0===b||a===b||isNaN(a)&&isNaN(b)}var d=this;return new o(function(e){var f=0,g=+b||0;return 1/0===Math.abs(g)&&(g=0),0>g?(e.onNext(!1),e.onCompleted(),p):d.subscribe(function(b){f++>=g&&c(b,a)&&(e.onNext(!0),e.onCompleted())},function(a){e.onError(a)},function(){e.onNext(!1),e.onCompleted()})},this)},m.contains=function(a,b){m.includes(a,b)},m.count=function(a,b){return a?this.filter(a,b).count():this.reduce(function(a){return a+1},0)},m.indexOf=function(a,b){var c=this;return new o(function(d){var e=0,f=+b||0;return 1/0===Math.abs(f)&&(f=0),0>f?(d.onNext(-1),d.onCompleted(),p):c.subscribe(function(b){e>=f&&b===a&&(d.onNext(e),d.onCompleted()),e++},function(a){d.onError(a)},function(){d.onNext(-1),d.onCompleted()})},c)},m.sum=function(a,b){return a&&v(a)?this.map(a,b).sum():this.reduce(function(a,b){return a+b},0)},m.minBy=function(a,b){return b||(b=u),e(this,a,function(a,c){return-1*b(a,c)})},m.min=function(a){return this.minBy(t,a).map(function(a){return f(a)})},m.maxBy=function(a,b){return b||(b=u),e(this,a,b)},m.max=function(a){return this.maxBy(t,a).map(function(a){return f(a)})},m.average=function(a,b){return a&&v(a)?this.map(a,b).average():this.reduce(function(a,b){return{sum:a.sum+b,count:a.count+1}},{sum:0,count:0}).map(function(a){if(0===a.count)throw new C;return a.sum/a.count})},m.sequenceEqual=function(a,b){var c=this;return b||(b=s),new o(function(d){var e=!1,f=!1,g=[],h=[],i=c.subscribe(function(a){var c,e;if(h.length>0){e=h.shift();try{c=b(e,a)}catch(i){return void d.onError(i)}c||(d.onNext(!1),d.onCompleted())}else f?(d.onNext(!1),d.onCompleted()):g.push(a)},function(a){d.onError(a)},function(){e=!0,0===g.length&&(h.length>0?(d.onNext(!1),d.onCompleted()):f&&(d.onNext(!0),d.onCompleted()))});(x(a)||y(a))&&(a=A(a)),w(a)&&(a=z(a));var j=a.subscribe(function(a){var c;if(g.length>0){var f=g.shift();try{c=b(f,a)}catch(i){return void d.onError(i)}c||(d.onNext(!1),d.onCompleted())}else e?(d.onNext(!1),d.onCompleted()):h.push(a)},function(a){d.onError(a)},function(){f=!0,0===h.length&&(g.length>0?(d.onNext(!1),d.onCompleted()):e&&(d.onNext(!0),d.onCompleted()))});return new n(i,j)},c)},m.elementAt=function(a){return g(this,a,!1)},m.elementAtOrDefault=function(a,b){return g(this,a,!0,b)},m.single=function(a,b){return a&&v(a)?this.where(a,b).single():h(this,!1)},m.singleOrDefault=function(a,b,c){return a&&v(a)?this.filter(a,c).singleOrDefault(null,b):h(this,!0,b)},m.first=function(a,b){return a?this.where(a,b).first():i(this,!1)},m.firstOrDefault=function(a,b){return a?this.where(a).firstOrDefault(null,b):i(this,!0,b)},m.last=function(a,b){return a?this.where(a,b).last():j(this,!1)},m.lastOrDefault=function(a,b,c){return a?this.where(a,c).lastOrDefault(null,b):j(this,!0,b)},m.find=function(a,b){return k(this,a,b,!1)},m.findIndex=function(a,b){return k(this,a,b,!0)},m.toSet=function(){if("undefined"==typeof a.Set)throw new TypeError;var b=this;return new o(function(c){var d=new a.Set;return b.subscribe(function(a){d.add(a)},function(a){c.onError(a)},function(){c.onNext(d),c.onCompleted()})},b)},m.toMap=function(b,c){if("undefined"==typeof a.Map)throw new TypeError;var d=this;return new o(function(e){var f=new a.Map;return d.subscribe(function(a){var d;try{d=b(a)}catch(g){return void e.onError(g)}var h=a;if(c)try{h=c(a)}catch(g){return void e.onError(g)}f.set(d,h)},function(a){e.onError(a)},function(){e.onNext(f),e.onCompleted()})},d)},c});
3
3
  //# sourceMappingURL=rx.aggregates.map
@@ -32,7 +32,6 @@
32
32
  // Defaults
33
33
  var noop = Rx.helpers.noop = function () { },
34
34
  notDefined = Rx.helpers.notDefined = function (x) { return typeof x === 'undefined'; },
35
- isScheduler = Rx.helpers.isScheduler = function (x) { return x instanceof Rx.Scheduler; },
36
35
  identity = Rx.helpers.identity = function (x) { return x; },
37
36
  pluck = Rx.helpers.pluck = function (property) { return function (x) { return x[property]; }; },
38
37
  just = Rx.helpers.just = function (value) { return function () { return value; }; },
@@ -45,7 +44,6 @@
45
44
  asArray = Rx.helpers.asArray = function () { return Array.prototype.slice.call(arguments); },
46
45
  not = Rx.helpers.not = function (a) { return !a; },
47
46
  isFunction = Rx.helpers.isFunction = (function () {
48
-
49
47
  var isFn = function (value) {
50
48
  return typeof value == 'function' || false;
51
49
  }
@@ -56,16 +54,14 @@
56
54
  return typeof value == 'function' && toString.call(value) == '[object Function]';
57
55
  };
58
56
  }
59
-
60
57
  return isFn;
61
58
  }());
62
59
 
63
- // Errors
64
- var sequenceContainsNoElements = 'Sequence contains no elements.';
65
- var argumentOutOfRange = 'Argument out of range';
66
- var objectDisposed = 'Object has been disposed';
67
- function checkDisposed(self) { if (self.isDisposed) { throw new Error(objectDisposed); } }
68
- function cloneArray(arr) { for(var a = [], i = 0, len = arr.length; i < len; i++) { a.push(arr[i]); } return a;}
60
+ function cloneArray(arr) {
61
+ var len = arr.length, a = new Array(len);
62
+ for(var i = 0; i < len; i++) { a[i] = arr[i]; }
63
+ return a;
64
+ }
69
65
 
70
66
  Rx.config.longStackSupport = false;
71
67
  var hasStacks = false;
@@ -163,6 +159,44 @@
163
159
  if (attempt3) { return [attempt3[1], Number(attempt3[2])]; }
164
160
  }
165
161
 
162
+ var EmptyError = Rx.EmptyError = function() {
163
+ this.message = 'Sequence contains no elements.';
164
+ Error.call(this);
165
+ };
166
+ EmptyError.prototype = Error.prototype;
167
+
168
+ var ObjectDisposedError = Rx.ObjectDisposedError = function() {
169
+ this.message = 'Object has been disposed';
170
+ Error.call(this);
171
+ };
172
+ ObjectDisposedError.prototype = Error.prototype;
173
+
174
+ var ArgumentOutOfRangeError = Rx.ArgumentOutOfRangeError = function () {
175
+ this.message = 'Argument out of range';
176
+ Error.call(this);
177
+ };
178
+ ArgumentOutOfRangeError.prototype = Error.prototype;
179
+
180
+ var NotSupportedError = Rx.NotSupportedError = function (message) {
181
+ this.message = message || 'This operation is not supported';
182
+ Error.call(this);
183
+ };
184
+ NotSupportedError.prototype = Error.prototype;
185
+
186
+ var NotImplementedError = Rx.NotImplementedError = function (message) {
187
+ this.message = message || 'This operation is not implemented';
188
+ Error.call(this);
189
+ };
190
+ NotImplementedError.prototype = Error.prototype;
191
+
192
+ var notImplemented = Rx.helpers.notImplemented = function () {
193
+ throw new NotImplementedError();
194
+ };
195
+
196
+ var notSupported = Rx.helpers.notSupported = function () {
197
+ throw new NotSupportedError();
198
+ };
199
+
166
200
  // Shim in iterator support
167
201
  var $iterator$ = (typeof Symbol === 'function' && Symbol.iterator) ||
168
202
  '_es6shim_iterator_';
@@ -827,13 +861,17 @@
827
861
  * @constructor
828
862
  */
829
863
  var CompositeDisposable = Rx.CompositeDisposable = function () {
830
- var args = [];
864
+ var args = [], i, len;
831
865
  if (Array.isArray(arguments[0])) {
832
866
  args = arguments[0];
867
+ len = args.length;
833
868
  } else {
834
- var len = arguments.length;
869
+ len = arguments.length;
835
870
  args = new Array(len);
836
- for(var i = 0; i < len; i++) { args[i] = arguments[i]; }
871
+ for(i = 0; i < len; i++) { args[i] = arguments[i]; }
872
+ }
873
+ for(i = 0; i < len; i++) {
874
+ if (!isDisposable(args[i])) { throw new TypeError('Not a disposable'); }
837
875
  }
838
876
  this.disposables = args;
839
877
  this.isDisposed = false;
@@ -920,51 +958,67 @@
920
958
  */
921
959
  var disposableEmpty = Disposable.empty = { dispose: noop };
922
960
 
923
- var SingleAssignmentDisposable = Rx.SingleAssignmentDisposable = (function () {
924
- function BooleanDisposable () {
925
- this.isDisposed = false;
926
- this.current = null;
927
- }
928
-
929
- var booleanDisposablePrototype = BooleanDisposable.prototype;
930
-
931
- /**
932
- * Gets the underlying disposable.
933
- * @return The underlying disposable.
934
- */
935
- booleanDisposablePrototype.getDisposable = function () {
936
- return this.current;
937
- };
961
+ /**
962
+ * Validates whether the given object is a disposable
963
+ * @param {Object} Object to test whether it has a dispose method
964
+ * @returns {Boolean} true if a disposable object, else false.
965
+ */
966
+ var isDisposable = Disposable.isDisposable = function (d) {
967
+ return d && isFunction(d.dispose);
968
+ };
938
969
 
939
- /**
940
- * Sets the underlying disposable.
941
- * @param {Disposable} value The new underlying disposable.
942
- */
943
- booleanDisposablePrototype.setDisposable = function (value) {
944
- var shouldDispose = this.isDisposed;
945
- if (!shouldDispose) {
946
- var old = this.current;
947
- this.current = value;
948
- }
949
- old && old.dispose();
950
- shouldDispose && value && value.dispose();
951
- };
970
+ var checkDisposed = Disposable.checkDisposed = function (disposable) {
971
+ if (disposable.isDisposed) { throw new ObjectDisposedError(); }
972
+ };
952
973
 
953
- /**
954
- * Disposes the underlying disposable as well as all future replacements.
955
- */
956
- booleanDisposablePrototype.dispose = function () {
957
- if (!this.isDisposed) {
958
- this.isDisposed = true;
959
- var old = this.current;
960
- this.current = null;
961
- }
962
- old && old.dispose();
963
- };
974
+ // Single assignment
975
+ var SingleAssignmentDisposable = Rx.SingleAssignmentDisposable = function () {
976
+ this.isDisposed = false;
977
+ this.current = null;
978
+ };
979
+ SingleAssignmentDisposable.prototype.getDisposable = function () {
980
+ return this.current;
981
+ };
982
+ SingleAssignmentDisposable.prototype.setDisposable = function (value) {
983
+ if (this.current) { throw new Error('Disposable has already been assigned'); }
984
+ var shouldDispose = this.isDisposed;
985
+ !shouldDispose && (this.current = value);
986
+ shouldDispose && value && value.dispose();
987
+ };
988
+ SingleAssignmentDisposable.prototype.dispose = function () {
989
+ if (!this.isDisposed) {
990
+ this.isDisposed = true;
991
+ var old = this.current;
992
+ this.current = null;
993
+ }
994
+ old && old.dispose();
995
+ };
964
996
 
965
- return BooleanDisposable;
966
- }());
967
- var SerialDisposable = Rx.SerialDisposable = SingleAssignmentDisposable;
997
+ // Multiple assignment disposable
998
+ var SerialDisposable = Rx.SerialDisposable = function () {
999
+ this.isDisposed = false;
1000
+ this.current = null;
1001
+ };
1002
+ SerialDisposable.prototype.getDisposable = function () {
1003
+ return this.current;
1004
+ };
1005
+ SerialDisposable.prototype.setDisposable = function (value) {
1006
+ var shouldDispose = this.isDisposed;
1007
+ if (!shouldDispose) {
1008
+ var old = this.current;
1009
+ this.current = value;
1010
+ }
1011
+ old && old.dispose();
1012
+ shouldDispose && value && value.dispose();
1013
+ };
1014
+ SerialDisposable.prototype.dispose = function () {
1015
+ if (!this.isDisposed) {
1016
+ this.isDisposed = true;
1017
+ var old = this.current;
1018
+ this.current = null;
1019
+ }
1020
+ old && old.dispose();
1021
+ };
968
1022
 
969
1023
  /**
970
1024
  * Represents a disposable resource that only disposes its underlying disposable resource when all dependent disposable objects have been disposed.
@@ -1076,6 +1130,11 @@
1076
1130
  this._scheduleAbsolute = scheduleAbsolute;
1077
1131
  }
1078
1132
 
1133
+ /** Determines whether the given object is a scheduler */
1134
+ Scheduler.isScheduler = function (s) {
1135
+ return s instanceof Scheduler;
1136
+ }
1137
+
1079
1138
  function invokeAction(scheduler, action) {
1080
1139
  action();
1081
1140
  return disposableEmpty;
@@ -1160,12 +1219,14 @@
1160
1219
  return Scheduler;
1161
1220
  }());
1162
1221
 
1163
- var normalizeTime = Scheduler.normalize;
1222
+ var normalizeTime = Scheduler.normalize, isScheduler = Scheduler.isScheduler;
1164
1223
 
1165
1224
  (function (schedulerProto) {
1225
+
1166
1226
  function invokeRecImmediate(scheduler, pair) {
1167
- var state = pair.first, action = pair.second, group = new CompositeDisposable(),
1168
- recursiveAction = function (state1) {
1227
+ var state = pair[0], action = pair[1], group = new CompositeDisposable();
1228
+
1229
+ function recursiveAction(state1) {
1169
1230
  action(state1, function (state2) {
1170
1231
  var isAdded = false, isDone = false,
1171
1232
  d = scheduler.scheduleWithState(state2, function (scheduler1, state3) {
@@ -1182,14 +1243,15 @@
1182
1243
  isAdded = true;
1183
1244
  }
1184
1245
  });
1185
- };
1246
+ }
1247
+
1186
1248
  recursiveAction(state);
1187
1249
  return group;
1188
1250
  }
1189
1251
 
1190
1252
  function invokeRecDate(scheduler, pair, method) {
1191
- var state = pair.first, action = pair.second, group = new CompositeDisposable(),
1192
- recursiveAction = function (state1) {
1253
+ var state = pair[0], action = pair[1], group = new CompositeDisposable();
1254
+ function recursiveAction(state1) {
1193
1255
  action(state1, function (state2, dueTime1) {
1194
1256
  var isAdded = false, isDone = false,
1195
1257
  d = scheduler[method](state2, dueTime1, function (scheduler1, state3) {
@@ -1232,7 +1294,7 @@
1232
1294
  * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
1233
1295
  */
1234
1296
  schedulerProto.scheduleRecursiveWithState = function (state, action) {
1235
- return this.scheduleWithState({ first: state, second: action }, invokeRecImmediate);
1297
+ return this.scheduleWithState([state, action], invokeRecImmediate);
1236
1298
  };
1237
1299
 
1238
1300
  /**
@@ -1253,7 +1315,7 @@
1253
1315
  * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
1254
1316
  */
1255
1317
  schedulerProto.scheduleRecursiveWithRelativeAndState = function (state, dueTime, action) {
1256
- return this._scheduleRelative({ first: state, second: action }, dueTime, function (s, p) {
1318
+ return this._scheduleRelative([state, action], dueTime, function (s, p) {
1257
1319
  return invokeRecDate(s, p, 'scheduleWithRelativeAndState');
1258
1320
  });
1259
1321
  };
@@ -1276,7 +1338,7 @@
1276
1338
  * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
1277
1339
  */
1278
1340
  schedulerProto.scheduleRecursiveWithAbsoluteAndState = function (state, dueTime, action) {
1279
- return this._scheduleAbsolute({ first: state, second: action }, dueTime, function (s, p) {
1341
+ return this._scheduleAbsolute([state, action], dueTime, function (s, p) {
1280
1342
  return invokeRecDate(s, p, 'scheduleWithAbsoluteAndState');
1281
1343
  });
1282
1344
  };
@@ -1302,16 +1364,10 @@
1302
1364
  * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort).
1303
1365
  */
1304
1366
  Scheduler.prototype.schedulePeriodicWithState = function(state, period, action) {
1305
- if (typeof root.setInterval === 'undefined') { throw new Error('Periodic scheduling not supported.'); }
1306
- var s = state;
1307
-
1308
- var id = root.setInterval(function () {
1309
- s = action(s);
1310
- }, period);
1311
-
1312
- return disposableCreate(function () {
1313
- root.clearInterval(id);
1314
- });
1367
+ if (typeof root.setInterval === 'undefined') { throw new NotSupportedError(); }
1368
+ period = normalizeTime(period);
1369
+ var s = state, id = root.setInterval(function () { s = action(s); }, period);
1370
+ return disposableCreate(function () { root.clearInterval(id); });
1315
1371
  };
1316
1372
 
1317
1373
  }(Scheduler.prototype));
@@ -1358,10 +1414,7 @@
1358
1414
 
1359
1415
  /** Gets a scheduler that schedules work immediately on the current thread. */
1360
1416
  var immediateScheduler = Scheduler.immediate = (function () {
1361
-
1362
1417
  function scheduleNow(state, action) { return action(this, state); }
1363
- function notSupported() { throw new Error('Not supported'); }
1364
-
1365
1418
  return new Scheduler(defaultNow, scheduleNow, notSupported, notSupported);
1366
1419
  }());
1367
1420
 
@@ -1371,12 +1424,10 @@
1371
1424
  var currentThreadScheduler = Scheduler.currentThread = (function () {
1372
1425
  var queue;
1373
1426
 
1374
- function runTrampoline (q) {
1375
- while (q.length > 0) {
1376
- var item = q.dequeue();
1377
- if (!item.isCancelled()) {
1378
- !item.isCancelled() && item.invoke();
1379
- }
1427
+ function runTrampoline () {
1428
+ while (queue.length > 0) {
1429
+ var item = queue.dequeue();
1430
+ !item.isCancelled() && item.invoke();
1380
1431
  }
1381
1432
  }
1382
1433
 
@@ -1386,44 +1437,36 @@
1386
1437
  if (!queue) {
1387
1438
  queue = new PriorityQueue(4);
1388
1439
  queue.enqueue(si);
1389
- try {
1390
- runTrampoline(queue);
1391
- } catch (e) {
1392
- throw e;
1393
- } finally {
1394
- queue = null;
1395
- }
1440
+
1441
+ var result = tryCatch(runTrampoline)();
1442
+ queue = null;
1443
+ if (result === errorObj) { return thrower(result.e); }
1396
1444
  } else {
1397
1445
  queue.enqueue(si);
1398
1446
  }
1399
1447
  return si.disposable;
1400
1448
  }
1401
1449
 
1402
- function notSupported() { throw new Error('Not supported'); }
1403
-
1404
1450
  var currentScheduler = new Scheduler(defaultNow, scheduleNow, notSupported, notSupported);
1405
-
1406
1451
  currentScheduler.scheduleRequired = function () { return !queue; };
1407
- currentScheduler.ensureTrampoline = function (action) {
1408
- if (!queue) { this.schedule(action); } else { action(); }
1409
- };
1410
1452
 
1411
1453
  return currentScheduler;
1412
1454
  }());
1413
1455
 
1414
- var scheduleMethod, clearMethod = noop;
1456
+ var scheduleMethod, clearMethod;
1457
+
1415
1458
  var localTimer = (function () {
1416
1459
  var localSetTimeout, localClearTimeout = noop;
1417
- if ('WScript' in this) {
1460
+ if (!!root.setTimeout) {
1461
+ localSetTimeout = root.setTimeout;
1462
+ localClearTimeout = root.clearTimeout;
1463
+ } else if (!!root.WScript) {
1418
1464
  localSetTimeout = function (fn, time) {
1419
- WScript.Sleep(time);
1465
+ root.WScript.Sleep(time);
1420
1466
  fn();
1421
1467
  };
1422
- } else if (!!root.setTimeout) {
1423
- localSetTimeout = root.setTimeout;
1424
- localClearTimeout = root.clearTimeout;
1425
1468
  } else {
1426
- throw new Error('No concurrency detected!');
1469
+ throw new NotSupportedError();
1427
1470
  }
1428
1471
 
1429
1472
  return {
@@ -1436,6 +1479,27 @@
1436
1479
 
1437
1480
  (function () {
1438
1481
 
1482
+ var nextHandle = 1, tasksByHandle = {}, currentlyRunning = false;
1483
+
1484
+ clearMethod = function (handle) {
1485
+ delete tasksByHandle[handle];
1486
+ };
1487
+
1488
+ function runTask(handle) {
1489
+ if (currentlyRunning) {
1490
+ localSetTimeout(function () { runTask(handle) }, 0);
1491
+ } else {
1492
+ var task = tasksByHandle[handle];
1493
+ if (task) {
1494
+ currentlyRunning = true;
1495
+ var result = tryCatch(task)();
1496
+ clearMethod(handle);
1497
+ currentlyRunning = false;
1498
+ if (result === errorObj) { return thrower(result.e); }
1499
+ }
1500
+ }
1501
+ }
1502
+
1439
1503
  var reNative = RegExp('^' +
1440
1504
  String(toString)
1441
1505
  .replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
@@ -1443,15 +1507,12 @@
1443
1507
  );
1444
1508
 
1445
1509
  var setImmediate = typeof (setImmediate = freeGlobal && moduleExports && freeGlobal.setImmediate) == 'function' &&
1446
- !reNative.test(setImmediate) && setImmediate,
1447
- clearImmediate = typeof (clearImmediate = freeGlobal && moduleExports && freeGlobal.clearImmediate) == 'function' &&
1448
- !reNative.test(clearImmediate) && clearImmediate;
1510
+ !reNative.test(setImmediate) && setImmediate;
1449
1511
 
1450
1512
  function postMessageSupported () {
1451
1513
  // Ensure not in a worker
1452
1514
  if (!root.postMessage || root.importScripts) { return false; }
1453
- var isAsync = false,
1454
- oldHandler = root.onmessage;
1515
+ var isAsync = false, oldHandler = root.onmessage;
1455
1516
  // Test for async
1456
1517
  root.onmessage = function () { isAsync = true; };
1457
1518
  root.postMessage('', '*');
@@ -1461,85 +1522,96 @@
1461
1522
  }
1462
1523
 
1463
1524
  // Use in order, setImmediate, nextTick, postMessage, MessageChannel, script readystatechanged, setTimeout
1464
- if (typeof setImmediate === 'function') {
1465
- scheduleMethod = setImmediate;
1466
- clearMethod = clearImmediate;
1525
+ if (isFunction(setImmediate)) {
1526
+ scheduleMethod = function (action) {
1527
+ var id = nextHandle++;
1528
+ tasksByHandle[id] = action;
1529
+ setImmediate(function () { runTask(id); });
1530
+
1531
+ return id;
1532
+ };
1467
1533
  } else if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') {
1468
- scheduleMethod = process.nextTick;
1534
+ scheduleMethod = function (action) {
1535
+ var id = nextHandle++;
1536
+ tasksByHandle[id] = action;
1537
+ process.nextTick(function () { runTask(id); });
1538
+
1539
+ return id;
1540
+ };
1469
1541
  } else if (postMessageSupported()) {
1470
- var MSG_PREFIX = 'ms.rx.schedule' + Math.random(),
1471
- tasks = {},
1472
- taskId = 0;
1542
+ var MSG_PREFIX = 'ms.rx.schedule' + Math.random();
1473
1543
 
1474
- var onGlobalPostMessage = function (event) {
1544
+ function onGlobalPostMessage(event) {
1475
1545
  // Only if we're a match to avoid any other global events
1476
1546
  if (typeof event.data === 'string' && event.data.substring(0, MSG_PREFIX.length) === MSG_PREFIX) {
1477
- var handleId = event.data.substring(MSG_PREFIX.length),
1478
- action = tasks[handleId];
1479
- action();
1480
- delete tasks[handleId];
1547
+ runTask(event.data.substring(MSG_PREFIX.length));
1481
1548
  }
1482
1549
  }
1483
1550
 
1484
1551
  if (root.addEventListener) {
1485
1552
  root.addEventListener('message', onGlobalPostMessage, false);
1553
+ } else if (root.attachEvent) {
1554
+ root.attachEvent('onmessage', onGlobalPostMessage);
1486
1555
  } else {
1487
- root.attachEvent('onmessage', onGlobalPostMessage, false);
1556
+ root.onmessage = onGlobalPostMessage;
1488
1557
  }
1489
1558
 
1490
1559
  scheduleMethod = function (action) {
1491
- var currentId = taskId++;
1492
- tasks[currentId] = action;
1560
+ var id = nextHandle++;
1561
+ tasksByHandle[id] = action;
1493
1562
  root.postMessage(MSG_PREFIX + currentId, '*');
1563
+ return id;
1494
1564
  };
1495
1565
  } else if (!!root.MessageChannel) {
1496
- var channel = new root.MessageChannel(),
1497
- channelTasks = {},
1498
- channelTaskId = 0;
1566
+ var channel = new root.MessageChannel();
1499
1567
 
1500
- channel.port1.onmessage = function (event) {
1501
- var id = event.data,
1502
- action = channelTasks[id];
1503
- action();
1504
- delete channelTasks[id];
1505
- };
1568
+ channel.port1.onmessage = function (e) { runTask(e.data); };
1506
1569
 
1507
1570
  scheduleMethod = function (action) {
1508
- var id = channelTaskId++;
1509
- channelTasks[id] = action;
1571
+ var id = nextHandle++;
1572
+ tasksByHandle[id] = action;
1510
1573
  channel.port2.postMessage(id);
1574
+ return id;
1511
1575
  };
1512
1576
  } else if ('document' in root && 'onreadystatechange' in root.document.createElement('script')) {
1513
1577
 
1514
1578
  scheduleMethod = function (action) {
1515
1579
  var scriptElement = root.document.createElement('script');
1580
+ var id = nextHandle++;
1581
+ tasksByHandle[id] = action;
1582
+
1516
1583
  scriptElement.onreadystatechange = function () {
1517
- action();
1584
+ runTask(id);
1518
1585
  scriptElement.onreadystatechange = null;
1519
1586
  scriptElement.parentNode.removeChild(scriptElement);
1520
1587
  scriptElement = null;
1521
1588
  };
1522
1589
  root.document.documentElement.appendChild(scriptElement);
1590
+ return id;
1523
1591
  };
1524
1592
 
1525
1593
  } else {
1526
- scheduleMethod = function (action) { return localSetTimeout(action, 0); };
1527
- clearMethod = localClearTimeout;
1594
+ scheduleMethod = function (action) {
1595
+ var id = nextHandle++;
1596
+ tasksByHandle[id] = action;
1597
+ localSetTimeout(function () {
1598
+ runTask(id);
1599
+ }, 0);
1600
+
1601
+ return id;
1602
+ };
1528
1603
  }
1529
1604
  }());
1530
1605
 
1531
1606
  /**
1532
1607
  * Gets a scheduler that schedules work via a timed callback based upon platform.
1533
1608
  */
1534
- var timeoutScheduler = Scheduler.timeout = (function () {
1609
+ var timeoutScheduler = Scheduler.timeout = Scheduler['default'] = (function () {
1535
1610
 
1536
1611
  function scheduleNow(state, action) {
1537
- var scheduler = this,
1538
- disposable = new SingleAssignmentDisposable();
1612
+ var scheduler = this, disposable = new SingleAssignmentDisposable();
1539
1613
  var id = scheduleMethod(function () {
1540
- if (!disposable.isDisposed) {
1541
- disposable.setDisposable(action(scheduler, state));
1542
- }
1614
+ !disposable.isDisposed && disposable.setDisposable(action(scheduler, state));
1543
1615
  });
1544
1616
  return new CompositeDisposable(disposable, disposableCreate(function () {
1545
1617
  clearMethod(id);
@@ -1547,16 +1619,10 @@
1547
1619
  }
1548
1620
 
1549
1621
  function scheduleRelative(state, dueTime, action) {
1550
- var scheduler = this,
1551
- dt = Scheduler.normalize(dueTime);
1552
- if (dt === 0) {
1553
- return scheduler.scheduleWithState(state, action);
1554
- }
1555
- var disposable = new SingleAssignmentDisposable();
1622
+ var scheduler = this, dt = Scheduler.normalize(dueTime), disposable = new SingleAssignmentDisposable();
1623
+ if (dt === 0) { return scheduler.scheduleWithState(state, action); }
1556
1624
  var id = localSetTimeout(function () {
1557
- if (!disposable.isDisposed) {
1558
- disposable.setDisposable(action(scheduler, state));
1559
- }
1625
+ !disposable.isDisposed && disposable.setDisposable(action(scheduler, state));
1560
1626
  }, dt);
1561
1627
  return new CompositeDisposable(disposable, disposableCreate(function () {
1562
1628
  localClearTimeout(id);
@@ -1646,9 +1712,13 @@
1646
1712
  * Represents a notification to an observer.
1647
1713
  */
1648
1714
  var Notification = Rx.Notification = (function () {
1649
- function Notification(kind, hasValue) {
1650
- this.hasValue = hasValue == null ? false : hasValue;
1715
+ function Notification(kind, value, exception, accept, acceptObservable, toString) {
1651
1716
  this.kind = kind;
1717
+ this.value = value;
1718
+ this.exception = exception;
1719
+ this._accept = accept;
1720
+ this._acceptObservable = acceptObservable;
1721
+ this.toString = toString;
1652
1722
  }
1653
1723
 
1654
1724
  /**
@@ -1674,10 +1744,10 @@
1674
1744
  * @returns {Observable} The observable sequence that surfaces the behavior of the notification upon subscription.
1675
1745
  */
1676
1746
  Notification.prototype.toObservable = function (scheduler) {
1677
- var notification = this;
1747
+ var self = this;
1678
1748
  isScheduler(scheduler) || (scheduler = immediateScheduler);
1679
1749
  return new AnonymousObservable(function (observer) {
1680
- return scheduler.schedule(function () {
1750
+ return scheduler.scheduleWithState(self, function (_, notification) {
1681
1751
  notification._acceptObservable(observer);
1682
1752
  notification.kind === 'N' && observer.onCompleted();
1683
1753
  });
@@ -1693,18 +1763,12 @@
1693
1763
  * @returns {Notification} The OnNext notification containing the value.
1694
1764
  */
1695
1765
  var notificationCreateOnNext = Notification.createOnNext = (function () {
1696
-
1697
- function _accept (onNext) { return onNext(this.value); }
1766
+ function _accept(onNext) { return onNext(this.value); }
1698
1767
  function _acceptObservable(observer) { return observer.onNext(this.value); }
1699
- function toString () { return 'OnNext(' + this.value + ')'; }
1768
+ function toString() { return 'OnNext(' + this.value + ')'; }
1700
1769
 
1701
1770
  return function (value) {
1702
- var notification = new Notification('N', true);
1703
- notification.value = value;
1704
- notification._accept = _accept;
1705
- notification._acceptObservable = _acceptObservable;
1706
- notification.toString = toString;
1707
- return notification;
1771
+ return new Notification('N', value, null, _accept, _acceptObservable, toString);
1708
1772
  };
1709
1773
  }());
1710
1774
 
@@ -1714,18 +1778,12 @@
1714
1778
  * @returns {Notification} The OnError notification containing the exception.
1715
1779
  */
1716
1780
  var notificationCreateOnError = Notification.createOnError = (function () {
1717
-
1718
1781
  function _accept (onNext, onError) { return onError(this.exception); }
1719
1782
  function _acceptObservable(observer) { return observer.onError(this.exception); }
1720
1783
  function toString () { return 'OnError(' + this.exception + ')'; }
1721
1784
 
1722
1785
  return function (e) {
1723
- var notification = new Notification('E');
1724
- notification.exception = e;
1725
- notification._accept = _accept;
1726
- notification._acceptObservable = _acceptObservable;
1727
- notification.toString = toString;
1728
- return notification;
1786
+ return new Notification('E', null, e, _accept, _acceptObservable, toString);
1729
1787
  };
1730
1788
  }());
1731
1789
 
@@ -1734,17 +1792,12 @@
1734
1792
  * @returns {Notification} The OnCompleted notification.
1735
1793
  */
1736
1794
  var notificationCreateOnCompleted = Notification.createOnCompleted = (function () {
1737
-
1738
1795
  function _accept (onNext, onError, onCompleted) { return onCompleted(); }
1739
1796
  function _acceptObservable(observer) { return observer.onCompleted(); }
1740
1797
  function toString () { return 'OnCompleted()'; }
1741
1798
 
1742
1799
  return function () {
1743
- var notification = new Notification('C');
1744
- notification._accept = _accept;
1745
- notification._acceptObservable = _acceptObservable;
1746
- notification.toString = toString;
1747
- return notification;
1800
+ return new Notification('C', null, null, _accept, _acceptObservable, toString);
1748
1801
  };
1749
1802
  }());
1750
1803
 
@@ -2019,10 +2072,6 @@
2019
2072
  __super__.call(this);
2020
2073
  }
2021
2074
 
2022
- function notImplemented() {
2023
- throw new Error('Method not implemented');
2024
- }
2025
-
2026
2075
  // Must be implemented by other observers
2027
2076
  AbstractObserver.prototype.next = notImplemented;
2028
2077
  AbstractObserver.prototype.error = notImplemented;
@@ -2122,58 +2171,46 @@
2122
2171
  return AnonymousObserver;
2123
2172
  }(AbstractObserver));
2124
2173
 
2125
- var CheckedObserver = (function (_super) {
2126
- inherits(CheckedObserver, _super);
2174
+ var CheckedObserver = (function (__super__) {
2175
+ inherits(CheckedObserver, __super__);
2127
2176
 
2128
- function CheckedObserver(observer) {
2129
- _super.call(this);
2130
- this._observer = observer;
2131
- this._state = 0; // 0 - idle, 1 - busy, 2 - done
2132
- }
2177
+ function CheckedObserver(observer) {
2178
+ __super__.call(this);
2179
+ this._observer = observer;
2180
+ this._state = 0; // 0 - idle, 1 - busy, 2 - done
2181
+ }
2133
2182
 
2134
- var CheckedObserverPrototype = CheckedObserver.prototype;
2183
+ var CheckedObserverPrototype = CheckedObserver.prototype;
2135
2184
 
2136
- CheckedObserverPrototype.onNext = function (value) {
2137
- this.checkAccess();
2138
- try {
2139
- this._observer.onNext(value);
2140
- } catch (e) {
2141
- throw e;
2142
- } finally {
2143
- this._state = 0;
2144
- }
2145
- };
2185
+ CheckedObserverPrototype.onNext = function (value) {
2186
+ this.checkAccess();
2187
+ var res = tryCatch(this._observer.onNext).call(this._observer, value);
2188
+ this._state = 0;
2189
+ res === errorObj && thrower(res.e);
2190
+ };
2146
2191
 
2147
- CheckedObserverPrototype.onError = function (err) {
2148
- this.checkAccess();
2149
- try {
2150
- this._observer.onError(err);
2151
- } catch (e) {
2152
- throw e;
2153
- } finally {
2154
- this._state = 2;
2155
- }
2156
- };
2192
+ CheckedObserverPrototype.onError = function (err) {
2193
+ this.checkAccess();
2194
+ var res = tryCatch(this._observer.onError).call(this._observer, err);
2195
+ this._state = 2;
2196
+ res === errorObj && thrower(res.e);
2197
+ };
2157
2198
 
2158
- CheckedObserverPrototype.onCompleted = function () {
2159
- this.checkAccess();
2160
- try {
2161
- this._observer.onCompleted();
2162
- } catch (e) {
2163
- throw e;
2164
- } finally {
2165
- this._state = 2;
2166
- }
2167
- };
2199
+ CheckedObserverPrototype.onCompleted = function () {
2200
+ this.checkAccess();
2201
+ var res = tryCatch(this._observer.onCompleted).call(this._observer);
2202
+ this._state = 2;
2203
+ res === errorObj && thrower(res.e);
2204
+ };
2168
2205
 
2169
- CheckedObserverPrototype.checkAccess = function () {
2170
- if (this._state === 1) { throw new Error('Re-entrancy detected'); }
2171
- if (this._state === 2) { throw new Error('Observer completed'); }
2172
- if (this._state === 0) { this._state = 1; }
2173
- };
2206
+ CheckedObserverPrototype.checkAccess = function () {
2207
+ if (this._state === 1) { throw new Error('Re-entrancy detected'); }
2208
+ if (this._state === 2) { throw new Error('Observer completed'); }
2209
+ if (this._state === 0) { this._state = 1; }
2210
+ };
2174
2211
 
2175
- return CheckedObserver;
2176
- }(Observer));
2212
+ return CheckedObserver;
2213
+ }(Observer));
2177
2214
 
2178
2215
  var ScheduledObserver = Rx.internals.ScheduledObserver = (function (__super__) {
2179
2216
  inherits(ScheduledObserver, __super__);
@@ -2350,25 +2387,21 @@
2350
2387
  })();
2351
2388
 
2352
2389
  var ObservableBase = Rx.ObservableBase = (function (__super__) {
2390
+ inherits(ObservableBase, __super__);
2353
2391
 
2354
- inherits(ObservableBase, __super__);
2355
-
2356
- // Fix subscriber to check for undefined or function returned to decorate as Disposable
2357
- function fixSubscriber(subscriber) {
2358
- if (subscriber && typeof subscriber.dispose === 'function') { return subscriber; }
2359
-
2360
- return typeof subscriber === 'function' ?
2361
- disposableCreate(subscriber) :
2362
- disposableEmpty;
2392
+ function fixSubscriber(subscriber) {
2393
+ return subscriber && isFunction(subscriber.dispose) ? subscriber :
2394
+ isFunction(subscriber) ? disposableCreate(subscriber) : disposableEmpty;
2363
2395
  }
2364
2396
 
2365
2397
  function setDisposable(s, state) {
2366
2398
  var ado = state[0], self = state[1];
2367
- try {
2368
- ado.setDisposable(fixSubscriber(self.subscribeCore(ado)));
2369
- } catch (e) {
2370
- if (!ado.fail(e)) { throw e; }
2399
+ var sub = tryCatch(self.subscribeCore).call(self, ado);
2400
+
2401
+ if (sub === errorObj) {
2402
+ if(!ado.fail(errorObj.e)) { return thrower(errorObj.e); }
2371
2403
  }
2404
+ ado.setDisposable(fixSubscriber(sub));
2372
2405
  }
2373
2406
 
2374
2407
  function subscribe(observer) {
@@ -2379,7 +2412,6 @@
2379
2412
  } else {
2380
2413
  setDisposable(null, state);
2381
2414
  }
2382
-
2383
2415
  return ado;
2384
2416
  }
2385
2417
 
@@ -2387,12 +2419,9 @@
2387
2419
  __super__.call(this, subscribe);
2388
2420
  }
2389
2421
 
2390
- ObservableBase.prototype.subscribeCore = function(observer) {
2391
- throw new Error('Not implemeneted');
2392
- }
2422
+ ObservableBase.prototype.subscribeCore = notImplemented;
2393
2423
 
2394
2424
  return ObservableBase;
2395
-
2396
2425
  }(Observable));
2397
2426
 
2398
2427
  /**
@@ -2466,7 +2495,7 @@
2466
2495
  */
2467
2496
  observableProto.toPromise = function (promiseCtor) {
2468
2497
  promiseCtor || (promiseCtor = Rx.config.Promise);
2469
- if (!promiseCtor) { throw new TypeError('Promise type not provided nor in Rx.config.Promise'); }
2498
+ if (!promiseCtor) { throw new NotSupportedError('Promise type not provided nor in Rx.config.Promise'); }
2470
2499
  var source = this;
2471
2500
  return new promiseCtor(function (resolve, reject) {
2472
2501
  // No cancellation can be done
@@ -2566,6 +2595,34 @@
2566
2595
  });
2567
2596
  };
2568
2597
 
2598
+ var EmptyObservable = (function(__super__) {
2599
+ inherits(EmptyObservable, __super__);
2600
+ function EmptyObservable(scheduler) {
2601
+ this.scheduler = scheduler;
2602
+ __super__.call(this);
2603
+ }
2604
+
2605
+ EmptyObservable.prototype.subscribeCore = function (observer) {
2606
+ var sink = new EmptySink(observer, this);
2607
+ return sink.run();
2608
+ };
2609
+
2610
+ function EmptySink(observer, parent) {
2611
+ this.observer = observer;
2612
+ this.parent = parent;
2613
+ }
2614
+
2615
+ function scheduleItem(s, state) {
2616
+ state.onCompleted();
2617
+ }
2618
+
2619
+ EmptySink.prototype.run = function () {
2620
+ return this.parent.scheduler.scheduleWithState(this.observer, scheduleItem);
2621
+ };
2622
+
2623
+ return EmptyObservable;
2624
+ }(ObservableBase));
2625
+
2569
2626
  /**
2570
2627
  * Returns an empty observable sequence, using the specified scheduler to send out the single OnCompleted message.
2571
2628
  *
@@ -2577,11 +2634,7 @@
2577
2634
  */
2578
2635
  var observableEmpty = Observable.empty = function (scheduler) {
2579
2636
  isScheduler(scheduler) || (scheduler = immediateScheduler);
2580
- return new AnonymousObservable(function (observer) {
2581
- return scheduler.schedule(function () {
2582
- observer.onCompleted();
2583
- });
2584
- });
2637
+ return new EmptyObservable(scheduler);
2585
2638
  };
2586
2639
 
2587
2640
  var FromObservable = (function(__super__) {
@@ -2753,7 +2806,7 @@
2753
2806
  inherits(FromArrayObservable, __super__);
2754
2807
  function FromArrayObservable(args, scheduler) {
2755
2808
  this.args = args;
2756
- this.scheduler = scheduler || currentThreadScheduler;
2809
+ this.scheduler = scheduler;
2757
2810
  __super__.call(this);
2758
2811
  }
2759
2812
 
@@ -2791,6 +2844,7 @@
2791
2844
  * @returns {Observable} The observable sequence whose elements are pulled from the given enumerable sequence.
2792
2845
  */
2793
2846
  var observableFromArray = Observable.fromArray = function (array, scheduler) {
2847
+ isScheduler(scheduler) || (scheduler = currentThreadScheduler);
2794
2848
  return new FromArrayObservable(array, scheduler)
2795
2849
  };
2796
2850
 
@@ -2809,9 +2863,9 @@
2809
2863
  */
2810
2864
  Observable.generate = function (initialState, condition, iterate, resultSelector, scheduler) {
2811
2865
  isScheduler(scheduler) || (scheduler = currentThreadScheduler);
2812
- return new AnonymousObservable(function (observer) {
2813
- var first = true, state = initialState;
2814
- return scheduler.scheduleRecursive(function (self) {
2866
+ return new AnonymousObservable(function (o) {
2867
+ var first = true;
2868
+ return scheduler.scheduleRecursiveWithState(initialState, function (state, self) {
2815
2869
  var hasResult, result;
2816
2870
  try {
2817
2871
  if (first) {
@@ -2820,24 +2874,22 @@
2820
2874
  state = iterate(state);
2821
2875
  }
2822
2876
  hasResult = condition(state);
2823
- if (hasResult) {
2824
- result = resultSelector(state);
2825
- }
2826
- } catch (exception) {
2827
- observer.onError(exception);
2828
- return;
2877
+ hasResult && (result = resultSelector(state));
2878
+ } catch (e) {
2879
+ return o.onError(e);
2829
2880
  }
2830
2881
  if (hasResult) {
2831
- observer.onNext(result);
2832
- self();
2882
+ o.onNext(result);
2883
+ self(state);
2833
2884
  } else {
2834
- observer.onCompleted();
2885
+ o.onCompleted();
2835
2886
  }
2836
2887
  });
2837
2888
  });
2838
2889
  };
2839
2890
 
2840
2891
  function observableOf (scheduler, array) {
2892
+ isScheduler(scheduler) || (scheduler = currentThreadScheduler);
2841
2893
  return new FromArrayObservable(array, scheduler);
2842
2894
  }
2843
2895
 
@@ -2848,7 +2900,7 @@
2848
2900
  Observable.of = function () {
2849
2901
  var len = arguments.length, args = new Array(len);
2850
2902
  for(var i = 0; i < len; i++) { args[i] = arguments[i]; }
2851
- return new FromArrayObservable(args);
2903
+ return new FromArrayObservable(args, currentThreadScheduler);
2852
2904
  };
2853
2905
 
2854
2906
  /**
@@ -2862,14 +2914,62 @@
2862
2914
  return new FromArrayObservable(args, scheduler);
2863
2915
  };
2864
2916
 
2917
+ var NeverObservable = (function(__super__) {
2918
+ inherits(NeverObservable, __super__);
2919
+ function NeverObservable() {
2920
+ __super__.call(this);
2921
+ }
2922
+
2923
+ NeverObservable.prototype.subscribeCore = function (observer) {
2924
+ return disposableEmpty;
2925
+ };
2926
+
2927
+ return NeverObservable;
2928
+ }(ObservableBase));
2929
+
2865
2930
  /**
2866
- * Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins).
2931
+ * Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins).
2867
2932
  * @returns {Observable} An observable sequence whose observers will never get called.
2868
2933
  */
2869
2934
  var observableNever = Observable.never = function () {
2870
- return new AnonymousObservable(function () {
2871
- return disposableEmpty;
2872
- });
2935
+ return new NeverObservable();
2936
+ };
2937
+
2938
+ var PairsObservable = (function(__super__) {
2939
+ inherits(PairsObservable, __super__);
2940
+ function PairsObservable(obj, scheduler) {
2941
+ this.obj = obj;
2942
+ this.keys = Object.keys(obj);
2943
+ this.scheduler = scheduler;
2944
+ __super__.call(this);
2945
+ }
2946
+
2947
+ PairsObservable.prototype.subscribeCore = function (observer) {
2948
+ var sink = new PairsSink(observer, this);
2949
+ return sink.run();
2950
+ };
2951
+
2952
+ return PairsObservable;
2953
+ }(ObservableBase));
2954
+
2955
+ function PairsSink(observer, parent) {
2956
+ this.observer = observer;
2957
+ this.parent = parent;
2958
+ }
2959
+
2960
+ PairsSink.prototype.run = function () {
2961
+ var observer = this.observer, obj = this.parent.obj, keys = this.parent.keys, len = keys.length;
2962
+ function loopRecursive(i, recurse) {
2963
+ if (i < len) {
2964
+ var key = keys[i];
2965
+ observer.onNext([key, obj[key]]);
2966
+ recurse(i + 1);
2967
+ } else {
2968
+ observer.onCompleted();
2969
+ }
2970
+ }
2971
+
2972
+ return this.parent.scheduler.scheduleRecursiveWithState(0, loopRecursive);
2873
2973
  };
2874
2974
 
2875
2975
  /**
@@ -2879,19 +2979,8 @@
2879
2979
  * @returns {Observable} An observable sequence of [key, value] pairs from the object.
2880
2980
  */
2881
2981
  Observable.pairs = function (obj, scheduler) {
2882
- scheduler || (scheduler = Rx.Scheduler.currentThread);
2883
- return new AnonymousObservable(function (observer) {
2884
- var keys = Object.keys(obj), len = keys.length;
2885
- return scheduler.scheduleRecursiveWithState(0, function (idx, self) {
2886
- if (idx < len) {
2887
- var key = keys[idx];
2888
- observer.onNext([key, obj[key]]);
2889
- self(idx + 1);
2890
- } else {
2891
- observer.onCompleted();
2892
- }
2893
- });
2894
- });
2982
+ scheduler || (scheduler = currentThreadScheduler);
2983
+ return new PairsObservable(obj, scheduler);
2895
2984
  };
2896
2985
 
2897
2986
  var RangeObservable = (function(__super__) {
@@ -2946,14 +3035,44 @@
2946
3035
  return new RangeObservable(start, count, scheduler);
2947
3036
  };
2948
3037
 
3038
+ var RepeatObservable = (function(__super__) {
3039
+ inherits(RepeatObservable, __super__);
3040
+ function RepeatObservable(value, repeatCount, scheduler) {
3041
+ this.value = value;
3042
+ this.repeatCount = repeatCount == null ? -1 : repeatCount;
3043
+ this.scheduler = scheduler;
3044
+ __super__.call(this);
3045
+ }
3046
+
3047
+ RepeatObservable.prototype.subscribeCore = function (observer) {
3048
+ var sink = new RepeatSink(observer, this);
3049
+ return sink.run();
3050
+ };
3051
+
3052
+ return RepeatObservable;
3053
+ }(ObservableBase));
3054
+
3055
+ function RepeatSink(observer, parent) {
3056
+ this.observer = observer;
3057
+ this.parent = parent;
3058
+ }
3059
+
3060
+ RepeatSink.prototype.run = function () {
3061
+ var observer = this.observer, value = this.parent.value;
3062
+ function loopRecursive(i, recurse) {
3063
+ if (i === -1 || i > 0) {
3064
+ observer.onNext(value);
3065
+ i > 0 && i--;
3066
+ }
3067
+ if (i === 0) { return observer.onCompleted(); }
3068
+ recurse(i);
3069
+ }
3070
+
3071
+ return this.parent.scheduler.scheduleRecursiveWithState(this.parent.repeatCount, loopRecursive);
3072
+ };
3073
+
2949
3074
  /**
2950
3075
  * Generates an observable sequence that repeats the given element the specified number of times, using the specified scheduler to send out observer messages.
2951
- *
2952
- * @example
2953
- * var res = Rx.Observable.repeat(42);
2954
- * var res = Rx.Observable.repeat(42, 4);
2955
- * 3 - res = Rx.Observable.repeat(42, 4, Rx.Scheduler.timeout);
2956
- * 4 - res = Rx.Observable.repeat(42, null, Rx.Scheduler.timeout);
2957
3076
  * @param {Mixed} value Element to repeat.
2958
3077
  * @param {Number} repeatCount [Optiona] Number of times to repeat the element. If not specified, repeats indefinitely.
2959
3078
  * @param {Scheduler} scheduler Scheduler to run the producer loop on. If not specified, defaults to Scheduler.immediate.
@@ -2961,31 +3080,81 @@
2961
3080
  */
2962
3081
  Observable.repeat = function (value, repeatCount, scheduler) {
2963
3082
  isScheduler(scheduler) || (scheduler = currentThreadScheduler);
2964
- return observableReturn(value, scheduler).repeat(repeatCount == null ? -1 : repeatCount);
3083
+ return new RepeatObservable(value, repeatCount, scheduler);
2965
3084
  };
2966
3085
 
3086
+ var JustObservable = (function(__super__) {
3087
+ inherits(JustObservable, __super__);
3088
+ function JustObservable(value, scheduler) {
3089
+ this.value = value;
3090
+ this.scheduler = scheduler;
3091
+ __super__.call(this);
3092
+ }
3093
+
3094
+ JustObservable.prototype.subscribeCore = function (observer) {
3095
+ var sink = new JustSink(observer, this);
3096
+ return sink.run();
3097
+ };
3098
+
3099
+ function JustSink(observer, parent) {
3100
+ this.observer = observer;
3101
+ this.parent = parent;
3102
+ }
3103
+
3104
+ function scheduleItem(s, state) {
3105
+ var value = state[0], observer = state[1];
3106
+ observer.onNext(value);
3107
+ observer.onCompleted();
3108
+ }
3109
+
3110
+ JustSink.prototype.run = function () {
3111
+ return this.parent.scheduler.scheduleWithState([this.parent.value, this.observer], scheduleItem);
3112
+ };
3113
+
3114
+ return JustObservable;
3115
+ }(ObservableBase));
3116
+
2967
3117
  /**
2968
3118
  * Returns an observable sequence that contains a single element, using the specified scheduler to send out observer messages.
2969
- * There is an alias called 'just', and 'returnValue' for browsers <IE9.
3119
+ * There is an alias called 'just' or browsers <IE9.
2970
3120
  * @param {Mixed} value Single element in the resulting observable sequence.
2971
3121
  * @param {Scheduler} scheduler Scheduler to send the single element on. If not specified, defaults to Scheduler.immediate.
2972
3122
  * @returns {Observable} An observable sequence containing the single specified element.
2973
3123
  */
2974
- var observableReturn = Observable['return'] = Observable.just = function (value, scheduler) {
3124
+ var observableReturn = Observable['return'] = Observable.just = Observable.returnValue = function (value, scheduler) {
2975
3125
  isScheduler(scheduler) || (scheduler = immediateScheduler);
2976
- return new AnonymousObservable(function (observer) {
2977
- return scheduler.schedule(function () {
2978
- observer.onNext(value);
2979
- observer.onCompleted();
2980
- });
2981
- });
3126
+ return new JustObservable(value, scheduler);
2982
3127
  };
2983
3128
 
2984
- /** @deprecated use return or just */
2985
- Observable.returnValue = function () {
2986
- //deprecate('returnValue', 'return or just');
2987
- return observableReturn.apply(null, arguments);
2988
- };
3129
+ var ThrowObservable = (function(__super__) {
3130
+ inherits(ThrowObservable, __super__);
3131
+ function ThrowObservable(error, scheduler) {
3132
+ this.error = error;
3133
+ this.scheduler = scheduler;
3134
+ __super__.call(this);
3135
+ }
3136
+
3137
+ ThrowObservable.prototype.subscribeCore = function (observer) {
3138
+ var sink = new ThrowSink(observer, this);
3139
+ return sink.run();
3140
+ };
3141
+
3142
+ function ThrowSink(observer, parent) {
3143
+ this.observer = observer;
3144
+ this.parent = parent;
3145
+ }
3146
+
3147
+ function scheduleItem(s, state) {
3148
+ var error = state[0], observer = state[1];
3149
+ observer.onError(error);
3150
+ }
3151
+
3152
+ ThrowSink.prototype.run = function () {
3153
+ return this.parent.scheduler.scheduleWithState([this.parent.error, this.observer], scheduleItem);
3154
+ };
3155
+
3156
+ return ThrowObservable;
3157
+ }(ObservableBase));
2989
3158
 
2990
3159
  /**
2991
3160
  * Returns an observable sequence that terminates with an exception, using the specified scheduler to send out the single onError message.
@@ -2994,19 +3163,9 @@
2994
3163
  * @param {Scheduler} scheduler Scheduler to send the exceptional termination call on. If not specified, defaults to Scheduler.immediate.
2995
3164
  * @returns {Observable} The observable sequence that terminates exceptionally with the specified exception object.
2996
3165
  */
2997
- var observableThrow = Observable['throw'] = Observable.throwError = function (error, scheduler) {
3166
+ var observableThrow = Observable['throw'] = Observable.throwError = Observable.throwException = function (error, scheduler) {
2998
3167
  isScheduler(scheduler) || (scheduler = immediateScheduler);
2999
- return new AnonymousObservable(function (observer) {
3000
- return scheduler.schedule(function () {
3001
- observer.onError(error);
3002
- });
3003
- });
3004
- };
3005
-
3006
- /** @deprecated use #some instead */
3007
- Observable.throwException = function () {
3008
- //deprecate('throwException', 'throwError');
3009
- return Observable.throwError.apply(null, arguments);
3168
+ return new ThrowObservable(error, scheduler);
3010
3169
  };
3011
3170
 
3012
3171
  /**
@@ -3202,24 +3361,23 @@
3202
3361
  var len = arguments.length, args = new Array(len);
3203
3362
  for(var i = 0; i < len; i++) { args[i] = arguments[i]; }
3204
3363
  var resultSelector = args.pop();
3205
- len--;
3206
3364
  Array.isArray(args[0]) && (args = args[0]);
3207
3365
 
3208
3366
  return new AnonymousObservable(function (o) {
3209
- var falseFactory = function () { return false; },
3210
- hasValue = arrayInitialize(len, falseFactory),
3367
+ var n = args.length,
3368
+ falseFactory = function () { return false; },
3369
+ hasValue = arrayInitialize(n, falseFactory),
3211
3370
  hasValueAll = false,
3212
- isDone = arrayInitialize(len, falseFactory),
3213
- values = new Array(len);
3371
+ isDone = arrayInitialize(n, falseFactory),
3372
+ values = new Array(n);
3214
3373
 
3215
3374
  function next(i) {
3216
3375
  hasValue[i] = true;
3217
3376
  if (hasValueAll || (hasValueAll = hasValue.every(identity))) {
3218
3377
  try {
3219
3378
  var res = resultSelector.apply(null, values);
3220
- } catch (ex) {
3221
- o.onError(ex);
3222
- return;
3379
+ } catch (e) {
3380
+ return o.onError(e);
3223
3381
  }
3224
3382
  o.onNext(res);
3225
3383
  } else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) {
@@ -3232,8 +3390,8 @@
3232
3390
  isDone.every(identity) && o.onCompleted();
3233
3391
  }
3234
3392
 
3235
- var subscriptions = new Array(len);
3236
- for (var idx = 0; idx < len; idx++) {
3393
+ var subscriptions = new Array(n);
3394
+ for (var idx = 0; idx < n; idx++) {
3237
3395
  (function (i) {
3238
3396
  var source = args[i], sad = new SingleAssignmentDisposable();
3239
3397
  isPromise(source) && (source = observableFromPromise(source));
@@ -3286,52 +3444,131 @@
3286
3444
  return this.merge(1);
3287
3445
  };
3288
3446
 
3289
- /**
3290
- * Merges an observable sequence of observable sequences into an observable sequence, limiting the number of concurrent subscriptions to inner sequences.
3291
- * Or merges two observable sequences into a single observable sequence.
3292
- *
3293
- * @example
3294
- * 1 - merged = sources.merge(1);
3295
- * 2 - merged = source.merge(otherSource);
3296
- * @param {Mixed} [maxConcurrentOrOther] Maximum number of inner observable sequences being subscribed to concurrently or the second observable sequence.
3297
- * @returns {Observable} The observable sequence that merges the elements of the inner sequences.
3298
- */
3299
- observableProto.merge = function (maxConcurrentOrOther) {
3300
- if (typeof maxConcurrentOrOther !== 'number') { return observableMerge(this, maxConcurrentOrOther); }
3301
- var sources = this;
3302
- return new AnonymousObservable(function (o) {
3303
- var activeCount = 0, group = new CompositeDisposable(), isStopped = false, q = [];
3447
+ var MergeObservable = (function (__super__) {
3448
+ inherits(MergeObservable, __super__);
3449
+
3450
+ function MergeObservable(source, maxConcurrent) {
3451
+ this.source = source;
3452
+ this.maxConcurrent = maxConcurrent;
3453
+ __super__.call(this);
3454
+ }
3455
+
3456
+ MergeObservable.prototype.subscribeCore = function(observer) {
3457
+ var g = new CompositeDisposable();
3458
+ g.add(this.source.subscribe(new MergeObserver(observer, this.maxConcurrent, g)));
3459
+ return g;
3460
+ };
3461
+
3462
+ return MergeObservable;
3304
3463
 
3305
- function subscribe(xs) {
3306
- var subscription = new SingleAssignmentDisposable();
3307
- group.add(subscription);
3464
+ }(ObservableBase));
3465
+
3466
+ var MergeObserver = (function () {
3467
+ function MergeObserver(o, max, g) {
3468
+ this.o = o;
3469
+ this.max = max;
3470
+ this.g = g;
3471
+ this.done = false;
3472
+ this.q = [];
3473
+ this.activeCount = 0;
3474
+ this.isStopped = false;
3475
+ }
3476
+ MergeObserver.prototype.handleSubscribe = function (xs) {
3477
+ var sad = new SingleAssignmentDisposable();
3478
+ this.g.add(sad);
3479
+ isPromise(xs) && (xs = observableFromPromise(xs));
3480
+ sad.setDisposable(xs.subscribe(new InnerObserver(this, sad)));
3481
+ };
3482
+ MergeObserver.prototype.onNext = function (innerSource) {
3483
+ if (this.isStopped) { return; }
3484
+ if(this.activeCount < this.max) {
3485
+ this.activeCount++;
3486
+ this.handleSubscribe(innerSource);
3487
+ } else {
3488
+ this.q.push(innerSource);
3489
+ }
3490
+ };
3491
+ MergeObserver.prototype.onError = function (e) {
3492
+ if (!this.isStopped) {
3493
+ this.isStopped = true;
3494
+ this.o.onError(e);
3495
+ }
3496
+ };
3497
+ MergeObserver.prototype.onCompleted = function () {
3498
+ if (!this.isStopped) {
3499
+ this.isStopped = true;
3500
+ this.done = true;
3501
+ this.activeCount === 0 && this.o.onCompleted();
3502
+ }
3503
+ };
3504
+ MergeObserver.prototype.dispose = function() { this.isStopped = true; };
3505
+ MergeObserver.prototype.fail = function (e) {
3506
+ if (!this.isStopped) {
3507
+ this.isStopped = true;
3508
+ this.o.onError(e);
3509
+ return true;
3510
+ }
3308
3511
 
3309
- // Check for promises support
3310
- isPromise(xs) && (xs = observableFromPromise(xs));
3512
+ return false;
3513
+ };
3311
3514
 
3312
- subscription.setDisposable(xs.subscribe(function (x) { o.onNext(x); }, function (e) { o.onError(e); }, function () {
3313
- group.remove(subscription);
3314
- if (q.length > 0) {
3315
- subscribe(q.shift());
3515
+ function InnerObserver(parent, sad) {
3516
+ this.parent = parent;
3517
+ this.sad = sad;
3518
+ this.isStopped = false;
3519
+ }
3520
+ InnerObserver.prototype.onNext = function (x) { if(!this.isStopped) { this.parent.o.onNext(x); } };
3521
+ InnerObserver.prototype.onError = function (e) {
3522
+ if (!this.isStopped) {
3523
+ this.isStopped = true;
3524
+ this.parent.o.onError(e);
3525
+ }
3526
+ };
3527
+ InnerObserver.prototype.onCompleted = function () {
3528
+ if(!this.isStopped) {
3529
+ this.isStopped = true;
3530
+ var parent = this.parent;
3531
+ parent.g.remove(this.sad);
3532
+ if (parent.q.length > 0) {
3533
+ parent.handleSubscribe(parent.q.shift());
3316
3534
  } else {
3317
- activeCount--;
3318
- isStopped && activeCount === 0 && o.onCompleted();
3535
+ parent.activeCount--;
3536
+ parent.done && parent.activeCount === 0 && parent.o.onCompleted();
3319
3537
  }
3320
- }));
3321
- }
3322
- group.add(sources.subscribe(function (innerSource) {
3323
- if (activeCount < maxConcurrentOrOther) {
3324
- activeCount++;
3325
- subscribe(innerSource);
3326
- } else {
3327
- q.push(innerSource);
3328
3538
  }
3329
- }, function (e) { o.onError(e); }, function () {
3330
- isStopped = true;
3331
- activeCount === 0 && o.onCompleted();
3332
- }));
3333
- return group;
3334
- }, sources);
3539
+ };
3540
+ InnerObserver.prototype.dispose = function() { this.isStopped = true; };
3541
+ InnerObserver.prototype.fail = function (e) {
3542
+ if (!this.isStopped) {
3543
+ this.isStopped = true;
3544
+ this.parent.o.onError(e);
3545
+ return true;
3546
+ }
3547
+
3548
+ return false;
3549
+ };
3550
+
3551
+ return MergeObserver;
3552
+ }());
3553
+
3554
+
3555
+
3556
+
3557
+
3558
+ /**
3559
+ * Merges an observable sequence of observable sequences into an observable sequence, limiting the number of concurrent subscriptions to inner sequences.
3560
+ * Or merges two observable sequences into a single observable sequence.
3561
+ *
3562
+ * @example
3563
+ * 1 - merged = sources.merge(1);
3564
+ * 2 - merged = source.merge(otherSource);
3565
+ * @param {Mixed} [maxConcurrentOrOther] Maximum number of inner observable sequences being subscribed to concurrently or the second observable sequence.
3566
+ * @returns {Observable} The observable sequence that merges the elements of the inner sequences.
3567
+ */
3568
+ observableProto.merge = function (maxConcurrentOrOther) {
3569
+ return typeof maxConcurrentOrOther !== 'number' ?
3570
+ observableMerge(this, maxConcurrentOrOther) :
3571
+ new MergeObservable(this, maxConcurrentOrOther);
3335
3572
  };
3336
3573
 
3337
3574
  /**
@@ -3357,35 +3594,188 @@
3357
3594
  return observableOf(scheduler, sources).mergeAll();
3358
3595
  };
3359
3596
 
3597
+ var MergeAllObservable = (function (__super__) {
3598
+ inherits(MergeAllObservable, __super__);
3599
+
3600
+ function MergeAllObservable(source) {
3601
+ this.source = source;
3602
+ __super__.call(this);
3603
+ }
3604
+
3605
+ MergeAllObservable.prototype.subscribeCore = function (observer) {
3606
+ var g = new CompositeDisposable(), m = new SingleAssignmentDisposable();
3607
+ g.add(m);
3608
+ m.setDisposable(this.source.subscribe(new MergeAllObserver(observer, g)));
3609
+ return g;
3610
+ };
3611
+
3612
+ return MergeAllObservable;
3613
+ }(ObservableBase));
3614
+
3615
+ var MergeAllObserver = (function() {
3616
+
3617
+ function MergeAllObserver(o, g) {
3618
+ this.o = o;
3619
+ this.g = g;
3620
+ this.isStopped = false;
3621
+ this.done = false;
3622
+ }
3623
+ MergeAllObserver.prototype.onNext = function(innerSource) {
3624
+ if(this.isStopped) { return; }
3625
+ var sad = new SingleAssignmentDisposable();
3626
+ this.g.add(sad);
3627
+
3628
+ isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
3629
+
3630
+ sad.setDisposable(innerSource.subscribe(new InnerObserver(this, this.g, sad)));
3631
+ };
3632
+ MergeAllObserver.prototype.onError = function (e) {
3633
+ if(!this.isStopped) {
3634
+ this.isStopped = true;
3635
+ this.o.onError(e);
3636
+ }
3637
+ };
3638
+ MergeAllObserver.prototype.onCompleted = function () {
3639
+ if(!this.isStopped) {
3640
+ this.isStopped = true;
3641
+ this.done = true;
3642
+ this.g.length === 1 && this.o.onCompleted();
3643
+ }
3644
+ };
3645
+ MergeAllObserver.prototype.dispose = function() { this.isStopped = true; };
3646
+ MergeAllObserver.prototype.fail = function (e) {
3647
+ if (!this.isStopped) {
3648
+ this.isStopped = true;
3649
+ this.o.onError(e);
3650
+ return true;
3651
+ }
3652
+
3653
+ return false;
3654
+ };
3655
+
3656
+ function InnerObserver(parent, g, sad) {
3657
+ this.parent = parent;
3658
+ this.g = g;
3659
+ this.sad = sad;
3660
+ this.isStopped = false;
3661
+ }
3662
+ InnerObserver.prototype.onNext = function (x) { if (!this.isStopped) { this.parent.o.onNext(x); } };
3663
+ InnerObserver.prototype.onError = function (e) {
3664
+ if(!this.isStopped) {
3665
+ this.isStopped = true;
3666
+ this.parent.o.onError(e);
3667
+ }
3668
+ };
3669
+ InnerObserver.prototype.onCompleted = function () {
3670
+ if(!this.isStopped) {
3671
+ var parent = this.parent;
3672
+ this.isStopped = true;
3673
+ parent.g.remove(this.sad);
3674
+ parent.done && parent.g.length === 1 && parent.o.onCompleted();
3675
+ }
3676
+ };
3677
+ InnerObserver.prototype.dispose = function() { this.isStopped = true; };
3678
+ InnerObserver.prototype.fail = function (e) {
3679
+ if (!this.isStopped) {
3680
+ this.isStopped = true;
3681
+ this.parent.o.onError(e);
3682
+ return true;
3683
+ }
3684
+
3685
+ return false;
3686
+ };
3687
+
3688
+ return MergeAllObserver;
3689
+
3690
+ }());
3691
+
3360
3692
  /**
3361
- * Merges an observable sequence of observable sequences into an observable sequence.
3362
- * @returns {Observable} The observable sequence that merges the elements of the inner sequences.
3363
- */
3693
+ * Merges an observable sequence of observable sequences into an observable sequence.
3694
+ * @returns {Observable} The observable sequence that merges the elements of the inner sequences.
3695
+ */
3364
3696
  observableProto.mergeAll = observableProto.mergeObservable = function () {
3365
- var sources = this;
3697
+ return new MergeAllObservable(this);
3698
+ };
3699
+
3700
+ var CompositeError = Rx.CompositeError = function(errors) {
3701
+ this.name = "NotImplementedError";
3702
+ this.innerErrors = errors;
3703
+ this.message = 'This contains multiple errors. Check the innerErrors';
3704
+ Error.call(this);
3705
+ }
3706
+ CompositeError.prototype = Error.prototype;
3707
+
3708
+ /**
3709
+ * Flattens an Observable that emits Observables into one Observable, in a way that allows an Observer to
3710
+ * receive all successfully emitted items from all of the source Observables without being interrupted by
3711
+ * an error notification from one of them.
3712
+ *
3713
+ * This behaves like Observable.prototype.mergeAll except that if any of the merged Observables notify of an
3714
+ * error via the Observer's onError, mergeDelayError will refrain from propagating that
3715
+ * error notification until all of the merged Observables have finished emitting items.
3716
+ * @param {Array | Arguments} args Arguments or an array to merge.
3717
+ * @returns {Observable} an Observable that emits all of the items emitted by the Observables emitted by the Observable
3718
+ */
3719
+ Observable.mergeDelayError = function() {
3720
+ var args;
3721
+ if (Array.isArray(arguments[0])) {
3722
+ args = arguments[0];
3723
+ } else {
3724
+ var len = arguments.length;
3725
+ args = new Array(len);
3726
+ for(var i = 0; i < len; i++) { args[i] = arguments[i]; }
3727
+ }
3728
+ var source = observableOf(null, args);
3729
+
3366
3730
  return new AnonymousObservable(function (o) {
3367
3731
  var group = new CompositeDisposable(),
3732
+ m = new SingleAssignmentDisposable(),
3368
3733
  isStopped = false,
3369
- m = new SingleAssignmentDisposable();
3734
+ errors = [];
3735
+
3736
+ function setCompletion() {
3737
+ if (errors.length === 0) {
3738
+ o.onCompleted();
3739
+ } else if (errors.length === 1) {
3740
+ o.onError(errors[0]);
3741
+ } else {
3742
+ o.onError(new CompositeError(errors));
3743
+ }
3744
+ }
3370
3745
 
3371
3746
  group.add(m);
3372
- m.setDisposable(sources.subscribe(function (innerSource) {
3373
- var innerSubscription = new SingleAssignmentDisposable();
3374
- group.add(innerSubscription);
3375
3747
 
3376
- // Check for promises support
3377
- isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
3748
+ m.setDisposable(source.subscribe(
3749
+ function (innerSource) {
3750
+ var innerSubscription = new SingleAssignmentDisposable();
3751
+ group.add(innerSubscription);
3752
+
3753
+ // Check for promises support
3754
+ isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
3378
3755
 
3379
- innerSubscription.setDisposable(innerSource.subscribe(function (x) { o.onNext(x); }, function (e) { o.onError(e); }, function () {
3380
- group.remove(innerSubscription);
3381
- isStopped && group.length === 1 && o.onCompleted();
3756
+ innerSubscription.setDisposable(innerSource.subscribe(
3757
+ function (x) { o.onNext(x); },
3758
+ function (e) {
3759
+ errors.push(e);
3760
+ group.remove(innerSubscription);
3761
+ isStopped && group.length === 1 && setCompletion();
3762
+ },
3763
+ function () {
3764
+ group.remove(innerSubscription);
3765
+ isStopped && group.length === 1 && setCompletion();
3766
+ }));
3767
+ },
3768
+ function (e) {
3769
+ errors.push(e);
3770
+ isStopped = true;
3771
+ group.length === 1 && setCompletion();
3772
+ },
3773
+ function () {
3774
+ isStopped = true;
3775
+ group.length === 1 && setCompletion();
3382
3776
  }));
3383
- }, function (e) { o.onError(e); }, function () {
3384
- isStopped = true;
3385
- group.length === 1 && o.onCompleted();
3386
- }));
3387
3777
  return group;
3388
- }, sources);
3778
+ });
3389
3779
  };
3390
3780
 
3391
3781
  /**
@@ -3525,7 +3915,8 @@
3525
3915
  * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
3526
3916
  */
3527
3917
  observableProto.withLatestFrom = function () {
3528
- for(var args = [], i = 0, len = arguments.length; i < len; i++) { args.push(arguments[i]); }
3918
+ var len = arguments.length, args = new Array(len)
3919
+ for(var i = 0; i < len; i++) { args[i] = arguments[i]; }
3529
3920
  var resultSelector = args.pop(), source = this;
3530
3921
 
3531
3922
  if (typeof source === 'undefined') {
@@ -3826,10 +4217,12 @@
3826
4217
  * @returns {Observable} The source sequence with the side-effecting behavior applied.
3827
4218
  */
3828
4219
  observableProto['do'] = observableProto.tap = observableProto.doAction = function (observerOrOnNext, onError, onCompleted) {
3829
- var source = this, tapObserver = typeof observerOrOnNext === 'function' || typeof observerOrOnNext === 'undefined'?
3830
- observerCreate(observerOrOnNext || noop, onError || noop, onCompleted || noop) :
3831
- observerOrOnNext;
4220
+ var source = this;
3832
4221
  return new AnonymousObservable(function (observer) {
4222
+ var tapObserver = !observerOrOnNext || isFunction(observerOrOnNext) ?
4223
+ observerCreate(observerOrOnNext || noop, onError || noop, onCompleted || noop) :
4224
+ observerOrOnNext;
4225
+
3833
4226
  return source.subscribe(function (x) {
3834
4227
  try {
3835
4228
  tapObserver.onNext(x);
@@ -4045,6 +4438,7 @@
4045
4438
  * @returns {Observable} An observable sequence containing the source sequence elements except for the bypassed ones at the end.
4046
4439
  */
4047
4440
  observableProto.skipLast = function (count) {
4441
+ if (count < 0) { throw new ArgumentOutOfRangeError(); }
4048
4442
  var source = this;
4049
4443
  return new AnonymousObservable(function (o) {
4050
4444
  var q = [];
@@ -4084,6 +4478,7 @@
4084
4478
  * @returns {Observable} An observable sequence containing the specified number of elements from the end of the source sequence.
4085
4479
  */
4086
4480
  observableProto.takeLast = function (count) {
4481
+ if (count < 0) { throw new ArgumentOutOfRangeError(); }
4087
4482
  var source = this;
4088
4483
  return new AnonymousObservable(function (o) {
4089
4484
  var q = [];
@@ -4133,12 +4528,12 @@
4133
4528
  var source = this;
4134
4529
  +count || (count = 0);
4135
4530
  Math.abs(count) === Infinity && (count = 0);
4136
- if (count <= 0) { throw new Error(argumentOutOfRange); }
4531
+ if (count <= 0) { throw new ArgumentOutOfRangeError(); }
4137
4532
  skip == null && (skip = count);
4138
4533
  +skip || (skip = 0);
4139
4534
  Math.abs(skip) === Infinity && (skip = 0);
4140
4535
 
4141
- if (skip <= 0) { throw new Error(argumentOutOfRange); }
4536
+ if (skip <= 0) { throw new ArgumentOutOfRangeError(); }
4142
4537
  return new AnonymousObservable(function (observer) {
4143
4538
  var m = new SingleAssignmentDisposable(),
4144
4539
  refCountDisposable = new RefCountDisposable(m),
@@ -4477,7 +4872,7 @@
4477
4872
 
4478
4873
  MapObservable.prototype.internalMap = function (selector, thisArg) {
4479
4874
  var self = this;
4480
- return new MapObservable(this.source, function (x, i, o) { return selector(self.selector(x, i, o), i, o); }, thisArg)
4875
+ return new MapObservable(this.source, function (x, i, o) { return selector.call(this, self.selector(x, i, o), i, o); }, thisArg)
4481
4876
  };
4482
4877
 
4483
4878
  MapObservable.prototype.subscribeCore = function (observer) {
@@ -4498,10 +4893,9 @@
4498
4893
 
4499
4894
  MapObserver.prototype.onNext = function(x) {
4500
4895
  if (this.isStopped) { return; }
4501
- try {
4502
- var result = this.selector(x, this.i++, this.source);
4503
- } catch (e) {
4504
- return this.observer.onError(e);
4896
+ var result = tryCatch(this.selector).call(this, x, this.i++, this.source);
4897
+ if (result === errorObj) {
4898
+ return this.observer.onError(result.e);
4505
4899
  }
4506
4900
  this.observer.onNext(result);
4507
4901
  };
@@ -4674,7 +5068,7 @@
4674
5068
  * @returns {Observable} An observable sequence that contains the elements that occur after the specified index in the input sequence.
4675
5069
  */
4676
5070
  observableProto.skip = function (count) {
4677
- if (count < 0) { throw new Error(argumentOutOfRange); }
5071
+ if (count < 0) { throw new ArgumentOutOfRangeError(); }
4678
5072
  var source = this;
4679
5073
  return new AnonymousObservable(function (o) {
4680
5074
  var remaining = count;
@@ -4727,7 +5121,7 @@
4727
5121
  * @returns {Observable} An observable sequence that contains the specified number of elements from the start of the input sequence.
4728
5122
  */
4729
5123
  observableProto.take = function (count, scheduler) {
4730
- if (count < 0) { throw new RangeError(argumentOutOfRange); }
5124
+ if (count < 0) { throw new ArgumentOutOfRangeError(); }
4731
5125
  if (count === 0) { return observableEmpty(scheduler); }
4732
5126
  var source = this;
4733
5127
  return new AnonymousObservable(function (o) {
@@ -4786,7 +5180,7 @@
4786
5180
 
4787
5181
  FilterObservable.prototype.internalFilter = function(predicate, thisArg) {
4788
5182
  var self = this;
4789
- return new FilterObservable(this.source, function(x, i, o) { return self.predicate(x, i, o) && predicate(x, i, o); }, thisArg);
5183
+ return new FilterObservable(this.source, function(x, i, o) { return self.predicate(x, i, o) && predicate.call(this, x, i, o); }, thisArg);
4790
5184
  };
4791
5185
 
4792
5186
  return FilterObservable;
@@ -4803,10 +5197,9 @@
4803
5197
 
4804
5198
  FilterObserver.prototype.onNext = function(x) {
4805
5199
  if (this.isStopped) { return; }
4806
- try {
4807
- var shouldYield = this.predicate(x, this.i++, this.source);
4808
- } catch (e) {
4809
- return this.observer.onError(e);
5200
+ var shouldYield = tryCatch(this.predicate).call(this, x, this.i++, this.source);
5201
+ if (shouldYield === errorObj) {
5202
+ return this.observer.onError(shouldYield.e);
4810
5203
  }
4811
5204
  shouldYield && this.observer.onNext(x);
4812
5205
  };
@@ -4873,7 +5266,7 @@
4873
5266
  }
4874
5267
 
4875
5268
  function firstOnly(x) {
4876
- if (x.length === 0) { throw new Error(sequenceContainsNoElements); }
5269
+ if (x.length === 0) { throw new EmptyError(); }
4877
5270
  return x[0];
4878
5271
  }
4879
5272
 
@@ -4886,7 +5279,6 @@
4886
5279
  * @returns {Observable} An observable sequence containing a single element with the final accumulator value.
4887
5280
  */
4888
5281
  observableProto.aggregate = function () {
4889
- //deprecate('aggregate', 'reduce');
4890
5282
  var hasSeed = false, accumulator, seed, source = this;
4891
5283
  if (arguments.length === 2) {
4892
5284
  hasSeed = true;
@@ -4908,15 +5300,14 @@
4908
5300
  hasAccumulation = true;
4909
5301
  }
4910
5302
  } catch (e) {
4911
- o.onError(e);
4912
- return;
5303
+ return o.onError(e);
4913
5304
  }
4914
5305
  },
4915
5306
  function (e) { o.onError(e); },
4916
5307
  function () {
4917
5308
  hasValue && o.onNext(accumulation);
4918
5309
  !hasValue && hasSeed && o.onNext(seed);
4919
- !hasValue && !hasSeed && o.onError(new Error(sequenceContainsNoElements));
5310
+ !hasValue && !hasSeed && o.onError(new EmptyError());
4920
5311
  o.onCompleted();
4921
5312
  }
4922
5313
  );
@@ -4949,15 +5340,14 @@
4949
5340
  hasAccumulation = true;
4950
5341
  }
4951
5342
  } catch (e) {
4952
- o.onError(e);
4953
- return;
5343
+ return o.onError(e);
4954
5344
  }
4955
5345
  },
4956
5346
  function (e) { o.onError(e); },
4957
5347
  function () {
4958
5348
  hasValue && o.onNext(accumulation);
4959
5349
  !hasValue && hasSeed && o.onNext(seed);
4960
- !hasValue && !hasSeed && o.onError(new Error(sequenceContainsNoElements));
5350
+ !hasValue && !hasSeed && o.onError(new EmptyError());
4961
5351
  o.onCompleted();
4962
5352
  }
4963
5353
  );
@@ -5055,6 +5445,7 @@
5055
5445
  //deprecate('contains', 'includes');
5056
5446
  observableProto.includes(searchElement, fromIndex);
5057
5447
  };
5448
+
5058
5449
  /**
5059
5450
  * Returns an observable sequence containing a value that represents how many elements in the specified observable sequence satisfy a condition if provided, else the count of items.
5060
5451
  * @example
@@ -5181,7 +5572,7 @@
5181
5572
  count: prev.count + 1
5182
5573
  };
5183
5574
  }, {sum: 0, count: 0 }).map(function (s) {
5184
- if (s.count === 0) { throw new Error(sequenceContainsNoElements); }
5575
+ if (s.count === 0) { throw new EmptyError(); }
5185
5576
  return s.sum / s.count;
5186
5577
  });
5187
5578
  };
@@ -5275,7 +5666,7 @@
5275
5666
  };
5276
5667
 
5277
5668
  function elementAtOrDefault(source, index, hasDefault, defaultValue) {
5278
- if (index < 0) { throw new Error(argumentOutOfRange); }
5669
+ if (index < 0) { throw new ArgumentOutOfRangeError(); }
5279
5670
  return new AnonymousObservable(function (o) {
5280
5671
  var i = index;
5281
5672
  return source.subscribe(function (x) {
@@ -5285,7 +5676,7 @@
5285
5676
  }
5286
5677
  }, function (e) { o.onError(e); }, function () {
5287
5678
  if (!hasDefault) {
5288
- o.onError(new Error(argumentOutOfRange));
5679
+ o.onError(new ArgumentOutOfRangeError());
5289
5680
  } else {
5290
5681
  o.onNext(defaultValue);
5291
5682
  o.onCompleted();
@@ -5330,7 +5721,7 @@
5330
5721
  }
5331
5722
  }, function (e) { o.onError(e); }, function () {
5332
5723
  if (!seenValue && !hasDefault) {
5333
- o.onError(new Error(sequenceContainsNoElements));
5724
+ o.onError(new EmptyError());
5334
5725
  } else {
5335
5726
  o.onNext(value);
5336
5727
  o.onCompleted();
@@ -5377,7 +5768,7 @@
5377
5768
  o.onCompleted();
5378
5769
  }, function (e) { o.onError(e); }, function () {
5379
5770
  if (!hasDefault) {
5380
- o.onError(new Error(sequenceContainsNoElements));
5771
+ o.onError(new EmptyError());
5381
5772
  } else {
5382
5773
  o.onNext(defaultValue);
5383
5774
  o.onCompleted();
@@ -5422,7 +5813,7 @@
5422
5813
  seenValue = true;
5423
5814
  }, function (e) { o.onError(e); }, function () {
5424
5815
  if (!seenValue && !hasDefault) {
5425
- o.onError(new Error(sequenceContainsNoElements));
5816
+ o.onError(new EmptyError());
5426
5817
  } else {
5427
5818
  o.onNext(value);
5428
5819
  o.onCompleted();
@@ -5815,17 +6206,19 @@
5815
6206
  */
5816
6207
  Observable.fromCallback = function (func, context, selector) {
5817
6208
  return function () {
5818
- for(var args = [], i = 0, len = arguments.length; i < len; i++) { args.push(arguments[i]); }
6209
+ var len = arguments.length, args = new Array(len)
6210
+ for(var i = 0; i < len; i++) { args[i] = arguments[i]; }
5819
6211
 
5820
6212
  return new AnonymousObservable(function (observer) {
5821
6213
  function handler() {
5822
- var results = arguments;
6214
+ var len = arguments.length, results = new Array(len);
6215
+ for(var i = 0; i < len; i++) { results[i] = arguments[i]; }
5823
6216
 
5824
6217
  if (selector) {
5825
6218
  try {
5826
- results = selector(results);
5827
- } catch (err) {
5828
- return observer.onError(err);
6219
+ results = selector.apply(context, results);
6220
+ } catch (e) {
6221
+ return observer.onError(e);
5829
6222
  }
5830
6223
 
5831
6224
  observer.onNext(results);
@@ -5855,7 +6248,8 @@
5855
6248
  */
5856
6249
  Observable.fromNodeCallback = function (func, context, selector) {
5857
6250
  return function () {
5858
- for(var args = [], i = 0, len = arguments.length; i < len; i++) { args.push(arguments[i]); }
6251
+ var len = arguments.length, args = new Array(len);
6252
+ for(var i = 0; i < len; i++) { args[i] = arguments[i]; }
5859
6253
 
5860
6254
  return new AnonymousObservable(function (observer) {
5861
6255
  function handler(err) {
@@ -5864,11 +6258,12 @@
5864
6258
  return;
5865
6259
  }
5866
6260
 
5867
- for(var results = [], i = 1, len = arguments.length; i < len; i++) { results.push(arguments[i]); }
6261
+ var len = arguments.length, results = [];
6262
+ for(var i = 1; i < len; i++) { results[i - 1] = arguments[i]; }
5868
6263
 
5869
6264
  if (selector) {
5870
6265
  try {
5871
- results = selector(results);
6266
+ results = selector.apply(context, results);
5872
6267
  } catch (e) {
5873
6268
  return observer.onError(e);
5874
6269
  }
@@ -6029,8 +6424,7 @@
6029
6424
  try {
6030
6425
  results = selector(arguments);
6031
6426
  } catch (err) {
6032
- observer.onError(err);
6033
- return
6427
+ return observer.onError(err);
6034
6428
  }
6035
6429
  }
6036
6430
 
@@ -6054,8 +6448,7 @@
6054
6448
  try {
6055
6449
  result = selector(arguments);
6056
6450
  } catch (err) {
6057
- observer.onError(err);
6058
- return;
6451
+ return observer.onError(err);
6059
6452
  }
6060
6453
  }
6061
6454
  observer.onNext(result);
@@ -6301,15 +6694,14 @@
6301
6694
  return this.source.subscribe(observer);
6302
6695
  }
6303
6696
 
6304
- function ControlledObservable (source, enableQueue) {
6697
+ function ControlledObservable (source, enableQueue, scheduler) {
6305
6698
  __super__.call(this, subscribe, source);
6306
- this.subject = new ControlledSubject(enableQueue);
6699
+ this.subject = new ControlledSubject(enableQueue, scheduler);
6307
6700
  this.source = source.multicast(this.subject).refCount();
6308
6701
  }
6309
6702
 
6310
6703
  ControlledObservable.prototype.request = function (numberOfItems) {
6311
- if (numberOfItems == null) { numberOfItems = -1; }
6312
- return this.subject.request(numberOfItems);
6704
+ return this.subject.request(numberOfItems == null ? -1 : numberOfItems);
6313
6705
  };
6314
6706
 
6315
6707
  return ControlledObservable;
@@ -6324,7 +6716,7 @@
6324
6716
 
6325
6717
  inherits(ControlledSubject, __super__);
6326
6718
 
6327
- function ControlledSubject(enableQueue) {
6719
+ function ControlledSubject(enableQueue, scheduler) {
6328
6720
  enableQueue == null && (enableQueue = true);
6329
6721
 
6330
6722
  __super__.call(this, subscribe);
@@ -6336,24 +6728,32 @@
6336
6728
  this.error = null;
6337
6729
  this.hasFailed = false;
6338
6730
  this.hasCompleted = false;
6339
- this.controlledDisposable = disposableEmpty;
6731
+ this.scheduler = scheduler || currentThreadScheduler;
6340
6732
  }
6341
6733
 
6342
6734
  addProperties(ControlledSubject.prototype, Observer, {
6343
6735
  onCompleted: function () {
6344
6736
  this.hasCompleted = true;
6345
- (!this.enableQueue || this.queue.length === 0) && this.subject.onCompleted();
6737
+ if (!this.enableQueue || this.queue.length === 0) {
6738
+ this.subject.onCompleted();
6739
+ } else {
6740
+ this.queue.push(Notification.createOnCompleted());
6741
+ }
6346
6742
  },
6347
6743
  onError: function (error) {
6348
6744
  this.hasFailed = true;
6349
6745
  this.error = error;
6350
- (!this.enableQueue || this.queue.length === 0) && this.subject.onError(error);
6746
+ if (!this.enableQueue || this.queue.length === 0) {
6747
+ this.subject.onError(error);
6748
+ } else {
6749
+ this.queue.push(Notification.createOnError(error));
6750
+ }
6351
6751
  },
6352
6752
  onNext: function (value) {
6353
6753
  var hasRequested = false;
6354
6754
 
6355
6755
  if (this.requestedCount === 0) {
6356
- this.enableQueue && this.queue.push(value);
6756
+ this.enableQueue && this.queue.push(Notification.createOnNext(value));
6357
6757
  } else {
6358
6758
  (this.requestedCount !== -1 && this.requestedCount-- === 0) && this.disposeCurrentRequest();
6359
6759
  hasRequested = true;
@@ -6362,43 +6762,39 @@
6362
6762
  },
6363
6763
  _processRequest: function (numberOfItems) {
6364
6764
  if (this.enableQueue) {
6365
- while (this.queue.length >= numberOfItems && numberOfItems > 0) {
6366
- this.subject.onNext(this.queue.shift());
6367
- numberOfItems--;
6765
+ while ((this.queue.length >= numberOfItems && numberOfItems > 0) ||
6766
+ (this.queue.length > 0 && this.queue[0].kind !== 'N')) {
6767
+ var first = this.queue.shift();
6768
+ first.accept(this.subject);
6769
+ if (first.kind === 'N') {
6770
+ numberOfItems--;
6771
+ } else {
6772
+ this.disposeCurrentRequest();
6773
+ this.queue = [];
6774
+ }
6368
6775
  }
6369
6776
 
6370
- return this.queue.length !== 0 ?
6371
- { numberOfItems: numberOfItems, returnValue: true } :
6372
- { numberOfItems: numberOfItems, returnValue: false };
6373
- }
6374
-
6375
- if (this.hasFailed) {
6376
- this.subject.onError(this.error);
6377
- this.controlledDisposable.dispose();
6378
- this.controlledDisposable = disposableEmpty;
6379
- } else if (this.hasCompleted) {
6380
- this.subject.onCompleted();
6381
- this.controlledDisposable.dispose();
6382
- this.controlledDisposable = disposableEmpty;
6777
+ return { numberOfItems : numberOfItems, returnValue: this.queue.length !== 0};
6383
6778
  }
6384
6779
 
6385
6780
  return { numberOfItems: numberOfItems, returnValue: false };
6386
6781
  },
6387
6782
  request: function (number) {
6388
6783
  this.disposeCurrentRequest();
6389
- var self = this, r = this._processRequest(number);
6784
+ var self = this;
6390
6785
 
6391
- var number = r.numberOfItems;
6392
- if (!r.returnValue) {
6393
- this.requestedCount = number;
6394
- this.requestedDisposable = disposableCreate(function () {
6395
- self.requestedCount = 0;
6396
- });
6786
+ this.requestedDisposable = this.scheduler.scheduleWithState(number,
6787
+ function(s, i) {
6788
+ var r = self._processRequest(i), remaining = r.numberOfItems;
6789
+ if (!r.returnValue) {
6790
+ self.requestedCount = remaining;
6791
+ self.requestedDisposable = disposableCreate(function () {
6792
+ self.requestedCount = 0;
6793
+ });
6794
+ }
6795
+ });
6397
6796
 
6398
- return this.requestedDisposable
6399
- } else {
6400
- return disposableEmpty;
6401
- }
6797
+ return this.requestedDisposable;
6402
6798
  },
6403
6799
  disposeCurrentRequest: function () {
6404
6800
  this.requestedDisposable.dispose();
@@ -6414,12 +6810,19 @@
6414
6810
  * @example
6415
6811
  * var source = Rx.Observable.interval(100).controlled();
6416
6812
  * source.request(3); // Reads 3 values
6417
- * @param {Observable} pauser The observable sequence used to pause the underlying sequence.
6813
+ * @param {bool} enableQueue truthy value to determine if values should be queued pending the next request
6814
+ * @param {Scheduler} scheduler determines how the requests will be scheduled
6418
6815
  * @returns {Observable} The observable sequence which is paused based upon the pauser.
6419
6816
  */
6420
- observableProto.controlled = function (enableQueue) {
6817
+ observableProto.controlled = function (enableQueue, scheduler) {
6818
+
6819
+ if (enableQueue && isScheduler(enableQueue)) {
6820
+ scheduler = enableQueue;
6821
+ enableQueue = true;
6822
+ }
6823
+
6421
6824
  if (enableQueue == null) { enableQueue = true; }
6422
- return new ControlledObservable(this, enableQueue);
6825
+ return new ControlledObservable(this, enableQueue, scheduler);
6423
6826
  };
6424
6827
 
6425
6828
  var StopAndWaitObservable = (function (__super__) {
@@ -6576,6 +6979,38 @@
6576
6979
  return new WindowedObservable(this, windowSize);
6577
6980
  };
6578
6981
 
6982
+ /**
6983
+ * Pipes the existing Observable sequence into a Node.js Stream.
6984
+ * @param {Stream} dest The destination Node.js stream.
6985
+ * @returns {Stream} The destination stream.
6986
+ */
6987
+ observableProto.pipe = function (dest) {
6988
+ var source = this.pausableBuffered();
6989
+
6990
+ function onDrain() {
6991
+ source.resume();
6992
+ }
6993
+
6994
+ dest.addListener('drain', onDrain);
6995
+
6996
+ source.subscribe(
6997
+ function (x) {
6998
+ !dest.write(String(x)) && source.pause();
6999
+ },
7000
+ function (err) {
7001
+ dest.emit('error', err);
7002
+ },
7003
+ function () {
7004
+ // Hack check because STDIO is not closable
7005
+ !dest._isStdio && dest.end();
7006
+ dest.removeListener('drain', onDrain);
7007
+ });
7008
+
7009
+ source.resume();
7010
+
7011
+ return dest;
7012
+ };
7013
+
6579
7014
  /**
6580
7015
  * Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function. Each
6581
7016
  * subscription to the resulting sequence causes a separate multicast invocation, exposing the sequence resulting from the selector function's
@@ -6688,14 +7123,14 @@
6688
7123
  *
6689
7124
  * @param selector [Optional] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all the notifications of the source subject to the specified replay buffer trimming policy.
6690
7125
  * @param bufferSize [Optional] Maximum element count of the replay buffer.
6691
- * @param window [Optional] Maximum time length of the replay buffer.
7126
+ * @param windowSize [Optional] Maximum time length of the replay buffer.
6692
7127
  * @param scheduler [Optional] Scheduler where connected observers within the selector function will be invoked on.
6693
7128
  * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
6694
7129
  */
6695
- observableProto.replay = function (selector, bufferSize, window, scheduler) {
7130
+ observableProto.replay = function (selector, bufferSize, windowSize, scheduler) {
6696
7131
  return selector && isFunction(selector) ?
6697
- this.multicast(function () { return new ReplaySubject(bufferSize, window, scheduler); }, selector) :
6698
- this.multicast(new ReplaySubject(bufferSize, window, scheduler));
7132
+ this.multicast(function () { return new ReplaySubject(bufferSize, windowSize, scheduler); }, selector) :
7133
+ this.multicast(new ReplaySubject(bufferSize, windowSize, scheduler));
6699
7134
  };
6700
7135
 
6701
7136
  /**
@@ -6713,8 +7148,8 @@
6713
7148
  * @param scheduler [Optional] Scheduler where connected observers within the selector function will be invoked on.
6714
7149
  * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence.
6715
7150
  */
6716
- observableProto.shareReplay = function (bufferSize, window, scheduler) {
6717
- return this.replay(null, bufferSize, window, scheduler).refCount();
7151
+ observableProto.shareReplay = function (bufferSize, windowSize, scheduler) {
7152
+ return this.replay(null, bufferSize, windowSize, scheduler).refCount();
6718
7153
  };
6719
7154
 
6720
7155
  var InnerSubscription = function (subject, observer) {
@@ -6766,6 +7201,20 @@
6766
7201
  }
6767
7202
 
6768
7203
  addProperties(BehaviorSubject.prototype, Observer, {
7204
+ /**
7205
+ * Gets the current value or throws an exception.
7206
+ * Value is frozen after onCompleted is called.
7207
+ * After onError is called always throws the specified exception.
7208
+ * An exception is always thrown after dispose is called.
7209
+ * @returns {Mixed} The initial value passed to the constructor until onNext is called; after which, the last value passed to onNext.
7210
+ */
7211
+ getValue: function () {
7212
+ checkDisposed(this);
7213
+ if (this.hasError) {
7214
+ throw this.error;
7215
+ }
7216
+ return this.value;
7217
+ },
6769
7218
  /**
6770
7219
  * Indicates whether the subject has observers subscribed to it.
6771
7220
  * @returns {Boolean} Indicates whether the subject has observers subscribed to it.
@@ -6833,6 +7282,8 @@
6833
7282
  */
6834
7283
  var ReplaySubject = Rx.ReplaySubject = (function (__super__) {
6835
7284
 
7285
+ var maxSafeInteger = Math.pow(2, 53) - 1;
7286
+
6836
7287
  function createRemovableDisposable(subject, observer) {
6837
7288
  return disposableCreate(function () {
6838
7289
  observer.dispose();
@@ -6870,8 +7321,8 @@
6870
7321
  * @param {Scheduler} [scheduler] Scheduler the observers are invoked on.
6871
7322
  */
6872
7323
  function ReplaySubject(bufferSize, windowSize, scheduler) {
6873
- this.bufferSize = bufferSize == null ? Number.MAX_VALUE : bufferSize;
6874
- this.windowSize = windowSize == null ? Number.MAX_VALUE : windowSize;
7324
+ this.bufferSize = bufferSize == null ? maxSafeInteger : bufferSize;
7325
+ this.windowSize = windowSize == null ? maxSafeInteger : windowSize;
6875
7326
  this.scheduler = scheduler || currentThreadScheduler;
6876
7327
  this.q = [];
6877
7328
  this.observers = [];
@@ -7082,7 +7533,7 @@
7082
7533
  }
7083
7534
 
7084
7535
  function Dictionary(capacity, comparer) {
7085
- if (capacity < 0) { throw new Error('out of range'); }
7536
+ if (capacity < 0) { throw new ArgumentOutOfRangeError(); }
7086
7537
  if (capacity > 0) { this._initialize(capacity); }
7087
7538
 
7088
7539
  this.comparer = comparer || defaultComparer;
@@ -7999,7 +8450,7 @@
7999
8450
  this.onNext(Observable.empty());
8000
8451
  },
8001
8452
  onError: function (e) {
8002
- this.onNext(Observable.throwException(e));
8453
+ this.onNext(Observable.throwError(e));
8003
8454
  },
8004
8455
  onNext: function (v) {
8005
8456
  this.tail.onNext(v);
@@ -8702,9 +9153,9 @@
8702
9153
  *
8703
9154
  * @example
8704
9155
  * 1 - res = source.timestamp(); // produces { value: x, timestamp: ts }
8705
- * 2 - res = source.timestamp(Rx.Scheduler.timeout);
9156
+ * 2 - res = source.timestamp(Rx.Scheduler.default);
8706
9157
  *
8707
- * @param {Scheduler} [scheduler] Scheduler used to compute timestamps. If not specified, the timeout scheduler is used.
9158
+ * @param {Scheduler} [scheduler] Scheduler used to compute timestamps. If not specified, the default scheduler is used.
8708
9159
  * @returns {Observable} An observable sequence with timestamp information on values.
8709
9160
  */
8710
9161
  observableProto.timestamp = function (scheduler) {
@@ -8923,18 +9374,29 @@
8923
9374
  };
8924
9375
 
8925
9376
  /**
8926
- * Time shifts the observable sequence by delaying the subscription.
9377
+ * Time shifts the observable sequence by delaying the subscription with the specified relative time duration, using the specified scheduler to run timers.
8927
9378
  *
8928
9379
  * @example
8929
9380
  * 1 - res = source.delaySubscription(5000); // 5s
8930
- * 2 - res = source.delaySubscription(5000, Rx.Scheduler.timeout); // 5 seconds
9381
+ * 2 - res = source.delaySubscription(5000, Rx.Scheduler.default); // 5 seconds
8931
9382
  *
8932
- * @param {Number} dueTime Absolute or relative time to perform the subscription at.
9383
+ * @param {Number} dueTime Relative or absolute time shift of the subscription.
8933
9384
  * @param {Scheduler} [scheduler] Scheduler to run the subscription delay timer on. If not specified, the timeout scheduler is used.
8934
9385
  * @returns {Observable} Time-shifted sequence.
8935
9386
  */
8936
9387
  observableProto.delaySubscription = function (dueTime, scheduler) {
8937
- return this.delayWithSelector(observableTimer(dueTime, isScheduler(scheduler) ? scheduler : timeoutScheduler), observableEmpty);
9388
+ var scheduleMethod = dueTime instanceof Date ? 'scheduleWithAbsolute' : 'scheduleWithRelative';
9389
+ var source = this;
9390
+ isScheduler(scheduler) || (scheduler = timeoutScheduler);
9391
+ return new AnonymousObservable(function (o) {
9392
+ var d = new SerialDisposable();
9393
+
9394
+ d.setDisposable(scheduler[scheduleMethod](dueTime, function() {
9395
+ d.setDisposable(source.subscribe(o));
9396
+ }));
9397
+
9398
+ return d;
9399
+ }, this);
8938
9400
  };
8939
9401
 
8940
9402
  /**
@@ -8949,47 +9411,54 @@
8949
9411
  * @returns {Observable} Time-shifted sequence.
8950
9412
  */
8951
9413
  observableProto.delayWithSelector = function (subscriptionDelay, delayDurationSelector) {
8952
- var source = this, subDelay, selector;
8953
- if (typeof subscriptionDelay === 'function') {
8954
- selector = subscriptionDelay;
8955
- } else {
8956
- subDelay = subscriptionDelay;
8957
- selector = delayDurationSelector;
8958
- }
8959
- return new AnonymousObservable(function (observer) {
8960
- var delays = new CompositeDisposable(), atEnd = false, done = function () {
8961
- if (atEnd && delays.length === 0) { observer.onCompleted(); }
8962
- }, subscription = new SerialDisposable(), start = function () {
8963
- subscription.setDisposable(source.subscribe(function (x) {
8964
- var delay;
8965
- try {
8966
- delay = selector(x);
8967
- } catch (error) {
8968
- observer.onError(error);
8969
- return;
8970
- }
8971
- var d = new SingleAssignmentDisposable();
8972
- delays.add(d);
8973
- d.setDisposable(delay.subscribe(function () {
9414
+ var source = this, subDelay, selector;
9415
+ if (isFunction(subscriptionDelay)) {
9416
+ selector = subscriptionDelay;
9417
+ } else {
9418
+ subDelay = subscriptionDelay;
9419
+ selector = delayDurationSelector;
9420
+ }
9421
+ return new AnonymousObservable(function (observer) {
9422
+ var delays = new CompositeDisposable(), atEnd = false, subscription = new SerialDisposable();
9423
+
9424
+ function start() {
9425
+ subscription.setDisposable(source.subscribe(
9426
+ function (x) {
9427
+ var delay = tryCatch(selector)(x);
9428
+ if (delay === errorObj) { return observer.onError(delay.e); }
9429
+ var d = new SingleAssignmentDisposable();
9430
+ delays.add(d);
9431
+ d.setDisposable(delay.subscribe(
9432
+ function () {
8974
9433
  observer.onNext(x);
8975
9434
  delays.remove(d);
8976
9435
  done();
8977
- }, observer.onError.bind(observer), function () {
9436
+ },
9437
+ function (e) { observer.onError(e); },
9438
+ function () {
8978
9439
  observer.onNext(x);
8979
9440
  delays.remove(d);
8980
9441
  done();
8981
- }));
8982
- }, observer.onError.bind(observer), function () {
9442
+ }
9443
+ ))
9444
+ },
9445
+ function (e) { observer.onError(e); },
9446
+ function () {
8983
9447
  atEnd = true;
8984
9448
  subscription.dispose();
8985
9449
  done();
8986
- }));
8987
- };
9450
+ }
9451
+ ))
9452
+ }
9453
+
9454
+ function done () {
9455
+ atEnd && delays.length === 0 && observer.onCompleted();
9456
+ }
8988
9457
 
8989
9458
  if (!subDelay) {
8990
9459
  start();
8991
9460
  } else {
8992
- subscription.setDisposable(subDelay.subscribe(start, observer.onError.bind(observer), start));
9461
+ subscription.setDisposable(subDelay.subscribe(start, function (e) { observer.onError(e); }, start));
8993
9462
  }
8994
9463
 
8995
9464
  return new CompositeDisposable(subscription, delays);
@@ -9115,9 +9584,12 @@
9115
9584
  }, source);
9116
9585
  };
9117
9586
 
9118
- observableProto.throttleWithSelector = function () {
9587
+ /**
9588
+ * @deprecated use #debounceWithSelector instead.
9589
+ */
9590
+ observableProto.throttleWithSelector = function (durationSelector) {
9119
9591
  //deprecate('throttleWithSelector', 'debounceWithSelector');
9120
- return this.debounceWithSelector.apply(this, arguments);
9592
+ return this.debounceWithSelector(durationSelector);
9121
9593
  };
9122
9594
 
9123
9595
  /**
@@ -9459,32 +9931,32 @@
9459
9931
  observableProto.transduce = function(transducer) {
9460
9932
  var source = this;
9461
9933
 
9462
- function transformForObserver(observer) {
9934
+ function transformForObserver(o) {
9463
9935
  return {
9464
- init: function() {
9465
- return observer;
9936
+ '@@transducer/init': function() {
9937
+ return o;
9466
9938
  },
9467
- step: function(obs, input) {
9939
+ '@@transducer/step': function(obs, input) {
9468
9940
  return obs.onNext(input);
9469
9941
  },
9470
- result: function(obs) {
9942
+ '@@transducer/result': function(obs) {
9471
9943
  return obs.onCompleted();
9472
9944
  }
9473
9945
  };
9474
9946
  }
9475
9947
 
9476
- return new AnonymousObservable(function(observer) {
9477
- var xform = transducer(transformForObserver(observer));
9948
+ return new AnonymousObservable(function(o) {
9949
+ var xform = transducer(transformForObserver(o));
9478
9950
  return source.subscribe(
9479
9951
  function(v) {
9480
9952
  try {
9481
- xform.step(observer, v);
9953
+ xform['@@transducer/step'](o, v);
9482
9954
  } catch (e) {
9483
- observer.onError(e);
9955
+ o.onError(e);
9484
9956
  }
9485
9957
  },
9486
- observer.onError.bind(observer),
9487
- function() { xform.result(observer); }
9958
+ function (e) { o.onError(e); },
9959
+ function() { xform['@@transducer/result'](o); }
9488
9960
  );
9489
9961
  }, source);
9490
9962
  };
@@ -9492,10 +9964,6 @@
9492
9964
  /** Provides a set of extension methods for virtual time scheduling. */
9493
9965
  Rx.VirtualTimeScheduler = (function (__super__) {
9494
9966
 
9495
- function notImplemented() {
9496
- throw new Error('Not implemented');
9497
- }
9498
-
9499
9967
  function localNow() {
9500
9968
  return this.toDateTimeOffset(this.clock);
9501
9969
  }
@@ -9623,12 +10091,8 @@
9623
10091
  */
9624
10092
  VirtualTimeSchedulerPrototype.advanceTo = function (time) {
9625
10093
  var dueToClock = this.comparer(this.clock, time);
9626
- if (this.comparer(this.clock, time) > 0) {
9627
- throw new Error(argumentOutOfRange);
9628
- }
9629
- if (dueToClock === 0) {
9630
- return;
9631
- }
10094
+ if (this.comparer(this.clock, time) > 0) { throw new ArgumentOutOfRangeError(); }
10095
+ if (dueToClock === 0) { return; }
9632
10096
  if (!this.isEnabled) {
9633
10097
  this.isEnabled = true;
9634
10098
  do {
@@ -9651,7 +10115,7 @@
9651
10115
  VirtualTimeSchedulerPrototype.advanceBy = function (time) {
9652
10116
  var dt = this.add(this.clock, time),
9653
10117
  dueToClock = this.comparer(this.clock, dt);
9654
- if (dueToClock > 0) { throw new Error(argumentOutOfRange); }
10118
+ if (dueToClock > 0) { throw new ArgumentOutOfRangeError(); }
9655
10119
  if (dueToClock === 0) { return; }
9656
10120
 
9657
10121
  this.advanceTo(dt);
@@ -9663,7 +10127,7 @@
9663
10127
  */
9664
10128
  VirtualTimeSchedulerPrototype.sleep = function (time) {
9665
10129
  var dt = this.add(this.clock, time);
9666
- if (this.comparer(this.clock, dt) >= 0) { throw new Error(argumentOutOfRange); }
10130
+ if (this.comparer(this.clock, dt) >= 0) { throw new ArgumentOutOfRangeError(); }
9667
10131
 
9668
10132
  this.clock = dt;
9669
10133
  };
@@ -9769,27 +10233,24 @@
9769
10233
 
9770
10234
  // Fix subscriber to check for undefined or function returned to decorate as Disposable
9771
10235
  function fixSubscriber(subscriber) {
9772
- if (subscriber && typeof subscriber.dispose === 'function') { return subscriber; }
9773
-
9774
- return typeof subscriber === 'function' ?
9775
- disposableCreate(subscriber) :
9776
- disposableEmpty;
10236
+ return subscriber && isFunction(subscriber.dispose) ? subscriber :
10237
+ isFunction(subscriber) ? disposableCreate(subscriber) : disposableEmpty;
9777
10238
  }
9778
10239
 
9779
10240
  function setDisposable(s, state) {
9780
10241
  var ado = state[0], subscribe = state[1];
9781
- try {
9782
- ado.setDisposable(fixSubscriber(subscribe(ado)));
9783
- } catch (e) {
9784
- if (!ado.fail(e)) { throw e; }
10242
+ var sub = tryCatch(subscribe)(ado);
10243
+
10244
+ if (sub === errorObj) {
10245
+ if(!ado.fail(errorObj.e)) { return thrower(errorObj.e); }
9785
10246
  }
10247
+ ado.setDisposable(fixSubscriber(sub));
9786
10248
  }
9787
10249
 
9788
10250
  function AnonymousObservable(subscribe, parent) {
9789
10251
  this.source = parent;
9790
10252
 
9791
10253
  function s(observer) {
9792
-
9793
10254
  var ado = new AutoDetachObserver(observer), state = [ado, subscribe];
9794
10255
 
9795
10256
  if (currentThreadScheduler.scheduleRequired()) {
@@ -9797,7 +10258,6 @@
9797
10258
  } else {
9798
10259
  setDisposable(null, state);
9799
10260
  }
9800
-
9801
10261
  return ado;
9802
10262
  }
9803
10263
 
@@ -9820,35 +10280,23 @@
9820
10280
  var AutoDetachObserverPrototype = AutoDetachObserver.prototype;
9821
10281
 
9822
10282
  AutoDetachObserverPrototype.next = function (value) {
9823
- var noError = false;
9824
- try {
9825
- this.observer.onNext(value);
9826
- noError = true;
9827
- } catch (e) {
9828
- return thrower(e);
9829
- } finally {
9830
- !noError && this.dispose();
10283
+ var result = tryCatch(this.observer.onNext).call(this.observer, value);
10284
+ if (result === errorObj) {
10285
+ this.dispose();
10286
+ thrower(result.e);
9831
10287
  }
9832
10288
  };
9833
10289
 
9834
10290
  AutoDetachObserverPrototype.error = function (err) {
9835
- try {
9836
- this.observer.onError(err);
9837
- } catch (e) {
9838
- return thrower(e);
9839
- } finally {
9840
- this.dispose();
9841
- }
10291
+ var result = tryCatch(this.observer.onError).call(this.observer, err);
10292
+ this.dispose();
10293
+ result === errorObj && thrower(result.e);
9842
10294
  };
9843
10295
 
9844
10296
  AutoDetachObserverPrototype.completed = function () {
9845
- try {
9846
- this.observer.onCompleted();
9847
- } catch (e) {
9848
- return thrower(e);
9849
- } finally {
9850
- this.dispose();
9851
- }
10297
+ var result = tryCatch(this.observer.onCompleted).call(this.observer);
10298
+ this.dispose();
10299
+ result === errorObj && thrower(result.e);
9852
10300
  };
9853
10301
 
9854
10302
  AutoDetachObserverPrototype.setDisposable = function (value) { this.m.setDisposable(value); };