rxjs-rails 2.2.27 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +0 -3
  3. data/lib/rxjs/rails/version.rb +1 -1
  4. data/vendor/assets/javascripts/rx.aggregates.min.js +1 -1
  5. data/vendor/assets/javascripts/rx.all.compat.js +1545 -1441
  6. data/vendor/assets/javascripts/rx.all.compat.min.js +3 -3
  7. data/vendor/assets/javascripts/rx.all.js +1545 -1441
  8. data/vendor/assets/javascripts/rx.all.min.js +3 -3
  9. data/vendor/assets/javascripts/rx.async.compat.js +149 -152
  10. data/vendor/assets/javascripts/rx.async.compat.min.js +1 -1
  11. data/vendor/assets/javascripts/rx.async.js +140 -143
  12. data/vendor/assets/javascripts/rx.async.min.js +1 -1
  13. data/vendor/assets/javascripts/rx.backpressure.min.js +1 -1
  14. data/vendor/assets/javascripts/rx.binding.js +18 -18
  15. data/vendor/assets/javascripts/rx.binding.min.js +1 -1
  16. data/vendor/assets/javascripts/rx.coincidence.min.js +1 -1
  17. data/vendor/assets/javascripts/rx.compat.js +490 -339
  18. data/vendor/assets/javascripts/rx.compat.min.js +2 -2
  19. data/vendor/assets/javascripts/rx.core.compat.js +109 -141
  20. data/vendor/assets/javascripts/rx.core.compat.min.js +1 -1
  21. data/vendor/assets/javascripts/rx.core.js +109 -141
  22. data/vendor/assets/javascripts/rx.core.min.js +1 -1
  23. data/vendor/assets/javascripts/rx.experimental.js +129 -136
  24. data/vendor/assets/javascripts/rx.experimental.min.js +1 -1
  25. data/vendor/assets/javascripts/rx.joinpatterns.js +59 -59
  26. data/vendor/assets/javascripts/rx.joinpatterns.min.js +1 -1
  27. data/vendor/assets/javascripts/rx.js +490 -339
  28. data/vendor/assets/javascripts/rx.lite.compat.js +1099 -954
  29. data/vendor/assets/javascripts/rx.lite.compat.min.js +2 -2
  30. data/vendor/assets/javascripts/rx.lite.extras.min.js +1 -1
  31. data/vendor/assets/javascripts/rx.lite.js +1099 -954
  32. data/vendor/assets/javascripts/rx.lite.min.js +2 -2
  33. data/vendor/assets/javascripts/rx.min.js +2 -2
  34. data/vendor/assets/javascripts/rx.testing.min.js +1 -1
  35. data/vendor/assets/javascripts/rx.time.js +715 -747
  36. data/vendor/assets/javascripts/rx.time.min.js +1 -1
  37. data/vendor/assets/javascripts/rx.virtualtime.min.js +1 -1
  38. metadata +11 -10
@@ -54,8 +54,10 @@
54
54
  Observer = Rx.Observer,
55
55
  inherits = Rx.internals.inherits,
56
56
  addProperties = Rx.internals.addProperties,
57
- noop = Rx.helpers.noop,
58
- isPromise = Rx.helpers.isPromise,
57
+ helpers = Rx.helpers,
58
+ noop = helpers.noop,
59
+ isPromise = helpers.isPromise,
60
+ isScheduler = helpers.isScheduler,
59
61
  observableFromPromise = Observable.fromPromise;
60
62
 
61
63
  // Utilities
@@ -66,14 +68,13 @@
66
68
  }
67
69
 
68
70
  // Shim in iterator support
69
- var $iterator$ = (typeof Symbol === 'object' && Symbol.iterator) ||
71
+ var $iterator$ = (typeof Symbol === 'function' && Symbol.iterator) ||
70
72
  '_es6shim_iterator_';
71
- // Firefox ships a partial implementation using the name @@iterator.
72
- // https://bugzilla.mozilla.org/show_bug.cgi?id=907077#c14
73
- // So use that name if we detect it.
73
+ // Bug for mozilla version
74
74
  if (root.Set && typeof new root.Set()['@@iterator'] === 'function') {
75
75
  $iterator$ = '@@iterator';
76
76
  }
77
+
77
78
  var doneEnumerator = { done: true, value: undefined };
78
79
 
79
80
  function enumerableWhile(condition, source) {
@@ -174,6 +175,7 @@
174
175
  */
175
176
  Observable['case'] = Observable.switchCase = function (selector, sources, defaultSourceOrScheduler) {
176
177
  return observableDefer(function () {
178
+ isPromise(defaultSourceOrScheduler) && (defaultSourceOrScheduler = observableFromPromise(defaultSourceOrScheduler));
177
179
  defaultSourceOrScheduler || (defaultSourceOrScheduler = observableEmpty());
178
180
 
179
181
  typeof defaultSourceOrScheduler.now === 'function' && (defaultSourceOrScheduler = observableEmpty(defaultSourceOrScheduler));
@@ -185,69 +187,69 @@
185
187
  });
186
188
  };
187
189
 
188
- /**
189
- * Expands an observable sequence by recursively invoking selector.
190
- *
191
- * @param {Function} selector Selector function to invoke for each produced element, resulting in another sequence to which the selector will be invoked recursively again.
192
- * @param {Scheduler} [scheduler] Scheduler on which to perform the expansion. If not provided, this defaults to the current thread scheduler.
193
- * @returns {Observable} An observable sequence containing all the elements produced by the recursive expansion.
194
- */
195
- observableProto.expand = function (selector, scheduler) {
196
- scheduler || (scheduler = immediateScheduler);
197
- var source = this;
198
- return new AnonymousObservable(function (observer) {
199
- var q = [],
200
- m = new SerialDisposable(),
201
- d = new CompositeDisposable(m),
202
- activeCount = 0,
203
- isAcquired = false;
204
-
205
- var ensureActive = function () {
206
- var isOwner = false;
207
- if (q.length > 0) {
208
- isOwner = !isAcquired;
209
- isAcquired = true;
210
- }
211
- if (isOwner) {
212
- m.setDisposable(scheduler.scheduleRecursive(function (self) {
213
- var work;
214
- if (q.length > 0) {
215
- work = q.shift();
216
- } else {
217
- isAcquired = false;
218
- return;
219
- }
220
- var m1 = new SingleAssignmentDisposable();
221
- d.add(m1);
222
- m1.setDisposable(work.subscribe(function (x) {
223
- observer.onNext(x);
224
- var result = null;
225
- try {
226
- result = selector(x);
227
- } catch (e) {
228
- observer.onError(e);
229
- }
230
- q.push(result);
231
- activeCount++;
232
- ensureActive();
233
- }, observer.onError.bind(observer), function () {
234
- d.remove(m1);
235
- activeCount--;
236
- if (activeCount === 0) {
237
- observer.onCompleted();
238
- }
239
- }));
240
- self();
241
- }));
242
- }
243
- };
190
+ /**
191
+ * Expands an observable sequence by recursively invoking selector.
192
+ *
193
+ * @param {Function} selector Selector function to invoke for each produced element, resulting in another sequence to which the selector will be invoked recursively again.
194
+ * @param {Scheduler} [scheduler] Scheduler on which to perform the expansion. If not provided, this defaults to the current thread scheduler.
195
+ * @returns {Observable} An observable sequence containing all the elements produced by the recursive expansion.
196
+ */
197
+ observableProto.expand = function (selector, scheduler) {
198
+ isScheduler(scheduler) || (scheduler = immediateScheduler);
199
+ var source = this;
200
+ return new AnonymousObservable(function (observer) {
201
+ var q = [],
202
+ m = new SerialDisposable(),
203
+ d = new CompositeDisposable(m),
204
+ activeCount = 0,
205
+ isAcquired = false;
206
+
207
+ var ensureActive = function () {
208
+ var isOwner = false;
209
+ if (q.length > 0) {
210
+ isOwner = !isAcquired;
211
+ isAcquired = true;
212
+ }
213
+ if (isOwner) {
214
+ m.setDisposable(scheduler.scheduleRecursive(function (self) {
215
+ var work;
216
+ if (q.length > 0) {
217
+ work = q.shift();
218
+ } else {
219
+ isAcquired = false;
220
+ return;
221
+ }
222
+ var m1 = new SingleAssignmentDisposable();
223
+ d.add(m1);
224
+ m1.setDisposable(work.subscribe(function (x) {
225
+ observer.onNext(x);
226
+ var result = null;
227
+ try {
228
+ result = selector(x);
229
+ } catch (e) {
230
+ observer.onError(e);
231
+ }
232
+ q.push(result);
233
+ activeCount++;
234
+ ensureActive();
235
+ }, observer.onError.bind(observer), function () {
236
+ d.remove(m1);
237
+ activeCount--;
238
+ if (activeCount === 0) {
239
+ observer.onCompleted();
240
+ }
241
+ }));
242
+ self();
243
+ }));
244
+ }
245
+ };
244
246
 
245
- q.push(source);
246
- activeCount++;
247
- ensureActive();
248
- return d;
249
- });
250
- };
247
+ q.push(source);
248
+ activeCount++;
249
+ ensureActive();
250
+ return d;
251
+ });
252
+ };
251
253
 
252
254
  /**
253
255
  * Runs all observable sequences in parallel and collect their last elements.
@@ -390,82 +392,73 @@
390
392
  });
391
393
  };
392
394
 
393
- /**
394
- * Comonadic bind operator.
395
- * @param {Function} selector A transform function to apply to each element.
396
- * @param {Object} scheduler Scheduler used to execute the operation. If not specified, defaults to the ImmediateScheduler.
397
- * @returns {Observable} An observable sequence which results from the comonadic bind operation.
398
- */
399
- observableProto.manySelect = function (selector, scheduler) {
400
- scheduler || (scheduler = immediateScheduler);
401
- var source = this;
402
- return observableDefer(function () {
403
- var chain;
404
-
405
- return source
406
- .select(
407
- function (x) {
408
- var curr = new ChainObservable(x);
409
- if (chain) {
410
- chain.onNext(x);
411
- }
412
- chain = curr;
413
-
414
- return curr;
415
- })
416
- .doAction(
417
- noop,
418
- function (e) {
419
- if (chain) {
420
- chain.onError(e);
421
- }
422
- },
423
- function () {
424
- if (chain) {
425
- chain.onCompleted();
426
- }
427
- })
428
- .observeOn(scheduler)
429
- .select(function (x, i, o) { return selector(x, i, o); });
430
- });
431
- };
395
+ /**
396
+ * Comonadic bind operator.
397
+ * @param {Function} selector A transform function to apply to each element.
398
+ * @param {Object} scheduler Scheduler used to execute the operation. If not specified, defaults to the ImmediateScheduler.
399
+ * @returns {Observable} An observable sequence which results from the comonadic bind operation.
400
+ */
401
+ observableProto.manySelect = function (selector, scheduler) {
402
+ isScheduler(scheduler) || (scheduler = immediateScheduler);
403
+ var source = this;
404
+ return observableDefer(function () {
405
+ var chain;
432
406
 
433
- var ChainObservable = (function (_super) {
407
+ return source
408
+ .map(function (x) {
409
+ var curr = new ChainObservable(x);
434
410
 
435
- function subscribe (observer) {
436
- var self = this, g = new CompositeDisposable();
437
- g.add(currentThreadScheduler.schedule(function () {
438
- observer.onNext(self.head);
439
- g.add(self.tail.mergeObservable().subscribe(observer));
440
- }));
411
+ chain && chain.onNext(x);
412
+ chain = curr;
441
413
 
442
- return g;
443
- }
414
+ return curr;
415
+ })
416
+ .doAction(
417
+ noop,
418
+ function (e) { chain && chain.onError(e); },
419
+ function () { chain && chain.onCompleted(); }
420
+ )
421
+ .observeOn(scheduler)
422
+ .map(selector);
423
+ });
424
+ };
444
425
 
445
- inherits(ChainObservable, _super);
426
+ var ChainObservable = (function (__super__) {
446
427
 
447
- function ChainObservable(head) {
448
- _super.call(this, subscribe);
449
- this.head = head;
450
- this.tail = new AsyncSubject();
451
- }
428
+ function subscribe (observer) {
429
+ var self = this, g = new CompositeDisposable();
430
+ g.add(currentThreadScheduler.schedule(function () {
431
+ observer.onNext(self.head);
432
+ g.add(self.tail.mergeObservable().subscribe(observer));
433
+ }));
452
434
 
453
- addProperties(ChainObservable.prototype, Observer, {
454
- onCompleted: function () {
455
- this.onNext(Observable.empty());
456
- },
457
- onError: function (e) {
458
- this.onNext(Observable.throwException(e));
459
- },
460
- onNext: function (v) {
461
- this.tail.onNext(v);
462
- this.tail.onCompleted();
463
- }
464
- });
435
+ return g;
436
+ }
437
+
438
+ inherits(ChainObservable, __super__);
439
+
440
+ function ChainObservable(head) {
441
+ __super__.call(this, subscribe);
442
+ this.head = head;
443
+ this.tail = new AsyncSubject();
444
+ }
445
+
446
+ addProperties(ChainObservable.prototype, Observer, {
447
+ onCompleted: function () {
448
+ this.onNext(Observable.empty());
449
+ },
450
+ onError: function (e) {
451
+ this.onNext(Observable.throwException(e));
452
+ },
453
+ onNext: function (v) {
454
+ this.tail.onNext(v);
455
+ this.tail.onCompleted();
456
+ }
457
+ });
465
458
 
466
- return ChainObservable;
459
+ return ChainObservable;
467
460
 
468
- }(Observable));
461
+ }(Observable));
469
462
 
470
463
  return Rx;
471
464
  }));
@@ -1 +1 @@
1
- (function(t){var e={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},n=e[typeof window]&&window||this,r=e[typeof exports]&&exports&&!exports.nodeType&&exports,i=e[typeof module]&&module&&!module.nodeType&&module,o=(i&&i.exports===r&&r,e[typeof global]&&global);!o||o.global!==o&&o.window!==o||(n=o),"function"==typeof define&&define.amd?define(["rx","exports"],function(e,r){return n.Rx=t(n,r,e),n.Rx}):"object"==typeof module&&module&&module.exports===r?module.exports=t(n,module.exports,require("./rx")):n.Rx=t(n,{},n.Rx)}).call(this,function(t,e,n,r){function i(t,e){return 1===t.length&&Array.isArray(t[e])?t[e]:E.call(t)}function o(t,e){return new m(function(){return new b(function(){return t()?{done:!1,value:e}:{done:!0,value:r}})})}var s=n.Observable,u=s.prototype,c=n.AnonymousObservable,a=s.concat,h=s.defer,l=s.empty,f=n.Disposable.empty,p=n.CompositeDisposable,d=n.SerialDisposable,v=n.SingleAssignmentDisposable,b=n.internals.Enumerator,m=n.internals.Enumerable,y=m.forEach,w=n.Scheduler.immediate,g=n.Scheduler.currentThread,E=Array.prototype.slice,x=n.AsyncSubject,C=n.Observer,D=n.internals.inherits,S=n.internals.addProperties,N=n.helpers.noop,A=n.helpers.isPromise,_=s.fromPromise,O="object"==typeof Symbol&&Symbol.iterator||"_es6shim_iterator_";t.Set&&"function"==typeof(new t.Set)["@@iterator"]&&(O="@@iterator"),u.letBind=u.let=function(t){return t(this)},s["if"]=s.ifThen=function(t,e,n){return h(function(){return n||(n=l()),A(e)&&(e=_(e)),A(n)&&(n=_(n)),"function"==typeof n.now&&(n=l(n)),t()?e:n})},s["for"]=s.forIn=function(t,e){return y(t,e).concat()};var j=s["while"]=s.whileDo=function(t,e){return A(e)&&(e=_(e)),o(t,e).concat()};u.doWhile=function(t){return a([this,j(t,this)])},s["case"]=s.switchCase=function(t,e,n){return h(function(){n||(n=l()),"function"==typeof n.now&&(n=l(n));var r=e[t()];return A(r)&&(r=_(r)),r||n})},u.expand=function(t,e){e||(e=w);var n=this;return new c(function(i){var o=[],s=new d,u=new p(s),c=0,a=!1,h=function(){var n=!1;o.length>0&&(n=!a,a=!0),n&&s.setDisposable(e.scheduleRecursive(function(e){var n;if(!(o.length>0))return a=!1,r;n=o.shift();var s=new v;u.add(s),s.setDisposable(n.subscribe(function(e){i.onNext(e);var n=null;try{n=t(e)}catch(r){i.onError(r)}o.push(n),c++,h()},i.onError.bind(i),function(){u.remove(s),c--,0===c&&i.onCompleted()})),e()}))};return o.push(n),c++,h(),u})},s.forkJoin=function(){var t=i(arguments,0);return new c(function(e){var n=t.length;if(0===n)return e.onCompleted(),f;for(var i=new p,o=!1,s=Array(n),u=Array(n),c=Array(n),a=0;n>a;a++)(function(a){var h=t[a];A(h)&&(h=_(h)),i.add(h.subscribe(function(t){o||(s[a]=!0,c[a]=t)},function(t){o=!0,e.onError(t),i.dispose()},function(){if(!o){if(!s[a])return e.onCompleted(),r;u[a]=!0;for(var t=0;n>t;t++)if(!u[t])return;o=!0,e.onNext(c),e.onCompleted()}}))})(a);return i})},u.forkJoin=function(t,e){var n=this;return new c(function(i){var o,s,u=!1,c=!1,a=!1,h=!1,l=new v,f=new v;return A(t)&&(t=_(t)),l.setDisposable(n.subscribe(function(t){a=!0,o=t},function(t){f.dispose(),i.onError(t)},function(){if(u=!0,c)if(a)if(h){var t;try{t=e(o,s)}catch(n){return i.onError(n),r}i.onNext(t),i.onCompleted()}else i.onCompleted();else i.onCompleted()})),f.setDisposable(t.subscribe(function(t){h=!0,s=t},function(t){l.dispose(),i.onError(t)},function(){if(c=!0,u)if(a)if(h){var t;try{t=e(o,s)}catch(n){return i.onError(n),r}i.onNext(t),i.onCompleted()}else i.onCompleted();else i.onCompleted()})),new p(l,f)})},u.manySelect=function(t,e){e||(e=w);var n=this;return h(function(){var r;return n.select(function(t){var e=new R(t);return r&&r.onNext(t),r=e,e}).doAction(N,function(t){r&&r.onError(t)},function(){r&&r.onCompleted()}).observeOn(e).select(function(e,n,r){return t(e,n,r)})})};var R=function(t){function e(t){var e=this,n=new p;return n.add(g.schedule(function(){t.onNext(e.head),n.add(e.tail.mergeObservable().subscribe(t))})),n}function n(n){t.call(this,e),this.head=n,this.tail=new x}return D(n,t),S(n.prototype,C,{onCompleted:function(){this.onNext(s.empty())},onError:function(t){this.onNext(s.throwException(t))},onNext:function(t){this.tail.onNext(t),this.tail.onCompleted()}}),n}(s);return n});
1
+ (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","exports"],function(b,d){return c.Rx=a(c,d,b),c.Rx}):"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){return 1===a.length&&Array.isArray(a[b])?a[b]:v.call(a)}function f(a,b){return new r(function(){return new q(function(){return a()?{done:!1,value:b}:{done:!0,value:d}})})}var g=c.Observable,h=g.prototype,i=c.AnonymousObservable,j=g.concat,k=g.defer,l=g.empty,m=c.Disposable.empty,n=c.CompositeDisposable,o=c.SerialDisposable,p=c.SingleAssignmentDisposable,q=c.internals.Enumerator,r=c.internals.Enumerable,s=r.forEach,t=c.Scheduler.immediate,u=c.Scheduler.currentThread,v=Array.prototype.slice,w=c.AsyncSubject,x=c.Observer,y=c.internals.inherits,z=c.internals.addProperties,A=c.helpers,B=A.noop,C=A.isPromise,D=A.isScheduler,E=g.fromPromise,F="function"==typeof Symbol&&Symbol.iterator||"_es6shim_iterator_";a.Set&&"function"==typeof(new a.Set)["@@iterator"]&&(F="@@iterator");h.letBind=h.let=function(a){return a(this)},g["if"]=g.ifThen=function(a,b,c){return k(function(){return c||(c=l()),C(b)&&(b=E(b)),C(c)&&(c=E(c)),"function"==typeof c.now&&(c=l(c)),a()?b:c})},g["for"]=g.forIn=function(a,b){return s(a,b).concat()};var G=g["while"]=g.whileDo=function(a,b){return C(b)&&(b=E(b)),f(a,b).concat()};h.doWhile=function(a){return j([this,G(a,this)])},g["case"]=g.switchCase=function(a,b,c){return k(function(){C(c)&&(c=E(c)),c||(c=l()),"function"==typeof c.now&&(c=l(c));var d=b[a()];return C(d)&&(d=E(d)),d||c})},h.expand=function(a,b){D(b)||(b=t);var c=this;return new i(function(d){var e=[],f=new o,g=new n(f),h=0,i=!1,j=function(){var c=!1;e.length>0&&(c=!i,i=!0),c&&f.setDisposable(b.scheduleRecursive(function(b){var c;if(!(e.length>0))return void(i=!1);c=e.shift();var f=new p;g.add(f),f.setDisposable(c.subscribe(function(b){d.onNext(b);var c=null;try{c=a(b)}catch(f){d.onError(f)}e.push(c),h++,j()},d.onError.bind(d),function(){g.remove(f),h--,0===h&&d.onCompleted()})),b()}))};return e.push(c),h++,j(),g})},g.forkJoin=function(){var a=e(arguments,0);return new i(function(b){var c=a.length;if(0===c)return b.onCompleted(),m;for(var d=new n,e=!1,f=new Array(c),g=new Array(c),h=new Array(c),i=0;c>i;i++)!function(i){var j=a[i];C(j)&&(j=E(j)),d.add(j.subscribe(function(a){e||(f[i]=!0,h[i]=a)},function(a){e=!0,b.onError(a),d.dispose()},function(){if(!e){if(!f[i])return void b.onCompleted();g[i]=!0;for(var a=0;c>a;a++)if(!g[a])return;e=!0,b.onNext(h),b.onCompleted()}}))}(i);return d})},h.forkJoin=function(a,b){var c=this;return new i(function(d){var e,f,g=!1,h=!1,i=!1,j=!1,k=new p,l=new p;return C(a)&&(a=E(a)),k.setDisposable(c.subscribe(function(a){i=!0,e=a},function(a){l.dispose(),d.onError(a)},function(){if(g=!0,h)if(i)if(j){var a;try{a=b(e,f)}catch(c){return void d.onError(c)}d.onNext(a),d.onCompleted()}else d.onCompleted();else d.onCompleted()})),l.setDisposable(a.subscribe(function(a){j=!0,f=a},function(a){k.dispose(),d.onError(a)},function(){if(h=!0,g)if(i)if(j){var a;try{a=b(e,f)}catch(c){return void d.onError(c)}d.onNext(a),d.onCompleted()}else d.onCompleted();else d.onCompleted()})),new n(k,l)})},h.manySelect=function(a,b){D(b)||(b=t);var c=this;return k(function(){var d;return c.map(function(a){var b=new H(a);return d&&d.onNext(a),d=b,b}).doAction(B,function(a){d&&d.onError(a)},function(){d&&d.onCompleted()}).observeOn(b).map(a)})};var H=function(a){function b(a){var b=this,c=new n;return c.add(u.schedule(function(){a.onNext(b.head),c.add(b.tail.mergeObservable().subscribe(a))})),c}function c(c){a.call(this,b),this.head=c,this.tail=new w}return y(c,a),z(c.prototype,x,{onCompleted:function(){this.onNext(g.empty())},onError:function(a){this.onNext(g.throwException(a))},onNext:function(a){this.tail.onNext(a),this.tail.onCompleted()}}),c}(g);return c});
@@ -155,51 +155,51 @@
155
155
  * @param selector Selector that will be invoked with available values from the source sequences, in the same order of the sequences in the pattern.
156
156
  * @return Plan that produces the projected values, to be fed (with other plans) to the when operator.
157
157
  */
158
- Pattern.prototype.then = function (selector) {
158
+ Pattern.prototype.thenDo = function (selector) {
159
159
  return new Plan(this, selector);
160
160
  };
161
161
 
162
- function Plan(expression, selector) {
163
- this.expression = expression;
164
- this.selector = selector;
162
+ function Plan(expression, selector) {
163
+ this.expression = expression;
164
+ this.selector = selector;
165
+ }
166
+
167
+ Plan.prototype.activate = function (externalSubscriptions, observer, deactivate) {
168
+ var self = this;
169
+ var joinObservers = [];
170
+ for (var i = 0, len = this.expression.patterns.length; i < len; i++) {
171
+ joinObservers.push(planCreateObserver(externalSubscriptions, this.expression.patterns[i], observer.onError.bind(observer)));
165
172
  }
166
-
167
- Plan.prototype.activate = function (externalSubscriptions, observer, deactivate) {
168
- var self = this;
169
- var joinObservers = [];
170
- for (var i = 0, len = this.expression.patterns.length; i < len; i++) {
171
- joinObservers.push(planCreateObserver(externalSubscriptions, this.expression.patterns[i], observer.onError.bind(observer)));
172
- }
173
- var activePlan = new ActivePlan(joinObservers, function () {
174
- var result;
175
- try {
176
- result = self.selector.apply(self, arguments);
177
- } catch (exception) {
178
- observer.onError(exception);
179
- return;
180
- }
181
- observer.onNext(result);
182
- }, function () {
183
- for (var j = 0, jlen = joinObservers.length; j < jlen; j++) {
184
- joinObservers[j].removeActivePlan(activePlan);
185
- }
186
- deactivate(activePlan);
187
- });
188
- for (i = 0, len = joinObservers.length; i < len; i++) {
189
- joinObservers[i].addActivePlan(activePlan);
190
- }
191
- return activePlan;
192
- };
193
-
194
- function planCreateObserver(externalSubscriptions, observable, onError) {
195
- var entry = externalSubscriptions.get(observable);
196
- if (!entry) {
197
- var observer = new JoinObserver(observable, onError);
198
- externalSubscriptions.set(observable, observer);
199
- return observer;
200
- }
201
- return entry;
173
+ var activePlan = new ActivePlan(joinObservers, function () {
174
+ var result;
175
+ try {
176
+ result = self.selector.apply(self, arguments);
177
+ } catch (exception) {
178
+ observer.onError(exception);
179
+ return;
180
+ }
181
+ observer.onNext(result);
182
+ }, function () {
183
+ for (var j = 0, jlen = joinObservers.length; j < jlen; j++) {
184
+ joinObservers[j].removeActivePlan(activePlan);
185
+ }
186
+ deactivate(activePlan);
187
+ });
188
+ for (i = 0, len = joinObservers.length; i < len; i++) {
189
+ joinObservers[i].addActivePlan(activePlan);
190
+ }
191
+ return activePlan;
192
+ };
193
+
194
+ function planCreateObserver(externalSubscriptions, observable, onError) {
195
+ var entry = externalSubscriptions.get(observable);
196
+ if (!entry) {
197
+ var observer = new JoinObserver(observable, onError);
198
+ externalSubscriptions.set(observable, observer);
199
+ return observer;
202
200
  }
201
+ return entry;
202
+ }
203
203
 
204
204
  // Active Plan
205
205
  function ActivePlan(joinObserverArray, onNext, onCompleted) {
@@ -344,25 +344,25 @@
344
344
  return JoinObserver;
345
345
  } (AbstractObserver));
346
346
 
347
- /**
348
- * Creates a pattern that matches when both observable sequences have an available value.
349
- *
350
- * @param right Observable sequence to match with the current sequence.
351
- * @return {Pattern} Pattern object that matches when both observable sequences have an available value.
352
- */
353
- observableProto.and = function (right) {
354
- return new Pattern([this, right]);
355
- };
356
-
357
- /**
358
- * Matches when the observable sequence has an available value and projects the value.
359
- *
360
- * @param selector Selector that will be invoked for values in the source sequence.
361
- * @returns {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator.
362
- */
363
- observableProto.then = function (selector) {
364
- return new Pattern([this]).then(selector);
365
- };
347
+ /**
348
+ * Creates a pattern that matches when both observable sequences have an available value.
349
+ *
350
+ * @param right Observable sequence to match with the current sequence.
351
+ * @return {Pattern} Pattern object that matches when both observable sequences have an available value.
352
+ */
353
+ observableProto.and = function (right) {
354
+ return new Pattern([this, right]);
355
+ };
356
+
357
+ /**
358
+ * Matches when the observable sequence has an available value and projects the value.
359
+ *
360
+ * @param selector Selector that will be invoked for values in the source sequence.
361
+ * @returns {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator.
362
+ */
363
+ observableProto.thenDo = function (selector) {
364
+ return new Pattern([this]).thenDo(selector);
365
+ };
366
366
 
367
367
  /**
368
368
  * Joins together the results from several patterns.
@@ -1 +1 @@
1
- (function(t){var e={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},n=e[typeof window]&&window||this,r=e[typeof exports]&&exports&&!exports.nodeType&&exports,i=e[typeof module]&&module&&!module.nodeType&&module,o=(i&&i.exports===r&&r,e[typeof global]&&global);!o||o.global!==o&&o.window!==o||(n=o),"function"==typeof define&&define.amd?define(["rx","exports"],function(e,r){return n.Rx=t(n,r,e),n.Rx}):"object"==typeof module&&module&&module.exports===r?module.exports=t(n,module.exports,require("./rx")):n.Rx=t(n,{},n.Rx)}).call(this,function(t,e,n){function r(t,e){return 1===t.length&&Array.isArray(t[e])?t[e]:y.call(t)}function i(t){this.patterns=t}function o(t,e){this.expression=t,this.selector=e}function s(t,e,n){var r=t.get(e);if(!r){var i=new g(e,n);return t.set(e,i),i}return r}function u(t,e,n){var r,i;for(this.joinObserverArray=t,this.onNext=e,this.onCompleted=n,this.joinObservers=new w,r=0;this.joinObserverArray.length>r;r++)i=this.joinObserverArray[r],this.joinObservers.set(i,i)}var c=n.Observable,a=c.prototype,h=n.AnonymousObservable,l=c.throwException,f=n.Observer.create,p=n.SingleAssignmentDisposable,d=n.CompositeDisposable,v=n.internals.AbstractObserver,b=n.helpers.noop,m=(n.internals.isEqual,n.internals.inherits),y=Array.prototype.slice,w=function(){function t(){this.keys=[],this.values=[]}return t.prototype["delete"]=function(t){var e=this.keys.indexOf(t);return-1!==e&&(this.keys.splice(e,1),this.values.splice(e,1)),-1!==e},t.prototype.get=function(t,e){var n=this.keys.indexOf(t);return-1!==n?this.values[n]:e},t.prototype.set=function(t,e){var n=this.keys.indexOf(t);-1!==n&&(this.values[n]=e),this.values[this.keys.push(t)-1]=e},t.prototype.size=function(){return this.keys.length},t.prototype.has=function(t){return-1!==this.keys.indexOf(t)},t.prototype.getKeys=function(){return this.keys.slice(0)},t.prototype.getValues=function(){return this.values.slice(0)},t}();i.prototype.and=function(t){var e=this.patterns.slice(0);return e.push(t),new i(e)},i.prototype.then=function(t){return new o(this,t)},o.prototype.activate=function(t,e,n){for(var r=this,i=[],o=0,c=this.expression.patterns.length;c>o;o++)i.push(s(t,this.expression.patterns[o],e.onError.bind(e)));var a=new u(i,function(){var t;try{t=r.selector.apply(r,arguments)}catch(n){return e.onError(n),undefined}e.onNext(t)},function(){for(var t=0,e=i.length;e>t;t++)i[t].removeActivePlan(a);n(a)});for(o=0,c=i.length;c>o;o++)i[o].addActivePlan(a);return a},u.prototype.dequeue=function(){for(var t=this.joinObservers.getValues(),e=0,n=t.length;n>e;e++)t[e].queue.shift()},u.prototype.match=function(){var t,e,n,r,i,o=!0;for(e=0,n=this.joinObserverArray.length;n>e;e++)if(0===this.joinObserverArray[e].queue.length){o=!1;break}if(o){for(t=[],r=!1,e=0,n=this.joinObserverArray.length;n>e;e++)t.push(this.joinObserverArray[e].queue[0]),"C"===this.joinObserverArray[e].queue[0].kind&&(r=!0);if(r)this.onCompleted();else{for(this.dequeue(),i=[],e=0;t.length>e;e++)i.push(t[e].value);this.onNext.apply(this,i)}}};var g=function(t){function e(e,n){t.call(this),this.source=e,this.onError=n,this.queue=[],this.activePlans=[],this.subscription=new p,this.isDisposed=!1}m(e,t);var n=e.prototype;return n.next=function(t){if(!this.isDisposed){if("E"===t.kind)return this.onError(t.exception),undefined;this.queue.push(t);for(var e=this.activePlans.slice(0),n=0,r=e.length;r>n;n++)e[n].match()}},n.error=b,n.completed=b,n.addActivePlan=function(t){this.activePlans.push(t)},n.subscribe=function(){this.subscription.setDisposable(this.source.materialize().subscribe(this))},n.removeActivePlan=function(t){var e=this.activePlans.indexOf(t);this.activePlans.splice(e,1),0===this.activePlans.length&&this.dispose()},n.dispose=function(){t.prototype.dispose.call(this),this.isDisposed||(this.isDisposed=!0,this.subscription.dispose())},e}(v);return a.and=function(t){return new i([this,t])},a.then=function(t){return new i([this]).then(t)},c.when=function(){var t=r(arguments,0);return new h(function(e){var n,r,i,o,s,u,c=[],a=new w;u=f(e.onNext.bind(e),function(t){for(var n=a.getValues(),r=0,i=n.length;i>r;r++)n[r].onError(t);e.onError(t)},e.onCompleted.bind(e));try{for(r=0,i=t.length;i>r;r++)c.push(t[r].activate(a,u,function(t){var e=c.indexOf(t);c.splice(e,1),0===c.length&&u.onCompleted()}))}catch(h){l(h).subscribe(e)}for(n=new d,s=a.getValues(),r=0,i=s.length;i>r;r++)o=s[r],o.subscribe(),n.add(o);return n})},n});
1
+ (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","exports"],function(b,d){return c.Rx=a(c,d,b),c.Rx}):"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){function d(a,b){return 1===a.length&&Array.isArray(a[b])?a[b]:s.call(a)}function e(a){this.patterns=a}function f(a,b){this.expression=a,this.selector=b}function g(a,b,c){var d=a.get(b);if(!d){var e=new u(b,c);return a.set(b,e),e}return d}function h(a,b,c){var d,e;for(this.joinObserverArray=a,this.onNext=b,this.onCompleted=c,this.joinObservers=new t,d=0;d<this.joinObserverArray.length;d++)e=this.joinObserverArray[d],this.joinObservers.set(e,e)}var i=c.Observable,j=i.prototype,k=c.AnonymousObservable,l=i.throwException,m=c.Observer.create,n=c.SingleAssignmentDisposable,o=c.CompositeDisposable,p=c.internals.AbstractObserver,q=c.helpers.noop,r=(c.internals.isEqual,c.internals.inherits),s=Array.prototype.slice,t=function(){function a(){this.keys=[],this.values=[]}return a.prototype["delete"]=function(a){var b=this.keys.indexOf(a);return-1!==b&&(this.keys.splice(b,1),this.values.splice(b,1)),-1!==b},a.prototype.get=function(a,b){var c=this.keys.indexOf(a);return-1!==c?this.values[c]:b},a.prototype.set=function(a,b){var c=this.keys.indexOf(a);-1!==c&&(this.values[c]=b),this.values[this.keys.push(a)-1]=b},a.prototype.size=function(){return this.keys.length},a.prototype.has=function(a){return-1!==this.keys.indexOf(a)},a.prototype.getKeys=function(){return this.keys.slice(0)},a.prototype.getValues=function(){return this.values.slice(0)},a}();e.prototype.and=function(a){var b=this.patterns.slice(0);return b.push(a),new e(b)},e.prototype.thenDo=function(a){return new f(this,a)},f.prototype.activate=function(a,b,c){for(var d=this,e=[],f=0,i=this.expression.patterns.length;i>f;f++)e.push(g(a,this.expression.patterns[f],b.onError.bind(b)));var j=new h(e,function(){var a;try{a=d.selector.apply(d,arguments)}catch(c){return void b.onError(c)}b.onNext(a)},function(){for(var a=0,b=e.length;b>a;a++)e[a].removeActivePlan(j);c(j)});for(f=0,i=e.length;i>f;f++)e[f].addActivePlan(j);return j},h.prototype.dequeue=function(){for(var a=this.joinObservers.getValues(),b=0,c=a.length;c>b;b++)a[b].queue.shift()},h.prototype.match=function(){var a,b,c,d,e,f=!0;for(b=0,c=this.joinObserverArray.length;c>b;b++)if(0===this.joinObserverArray[b].queue.length){f=!1;break}if(f){for(a=[],d=!1,b=0,c=this.joinObserverArray.length;c>b;b++)a.push(this.joinObserverArray[b].queue[0]),"C"===this.joinObserverArray[b].queue[0].kind&&(d=!0);if(d)this.onCompleted();else{for(this.dequeue(),e=[],b=0;b<a.length;b++)e.push(a[b].value);this.onNext.apply(this,e)}}};var u=function(a){function b(b,c){a.call(this),this.source=b,this.onError=c,this.queue=[],this.activePlans=[],this.subscription=new n,this.isDisposed=!1}r(b,a);var c=b.prototype;return c.next=function(a){if(!this.isDisposed){if("E"===a.kind)return void this.onError(a.exception);this.queue.push(a);for(var b=this.activePlans.slice(0),c=0,d=b.length;d>c;c++)b[c].match()}},c.error=q,c.completed=q,c.addActivePlan=function(a){this.activePlans.push(a)},c.subscribe=function(){this.subscription.setDisposable(this.source.materialize().subscribe(this))},c.removeActivePlan=function(a){var b=this.activePlans.indexOf(a);this.activePlans.splice(b,1),0===this.activePlans.length&&this.dispose()},c.dispose=function(){a.prototype.dispose.call(this),this.isDisposed||(this.isDisposed=!0,this.subscription.dispose())},b}(p);return j.and=function(a){return new e([this,a])},j.thenDo=function(a){return new e([this]).thenDo(a)},i.when=function(){var a=d(arguments,0);return new k(function(b){var c,d,e,f,g,h,i=[],j=new t;h=m(b.onNext.bind(b),function(a){for(var c=j.getValues(),d=0,e=c.length;e>d;d++)c[d].onError(a);b.onError(a)},b.onCompleted.bind(b));try{for(d=0,e=a.length;e>d;d++)i.push(a[d].activate(j,h,function(a){var b=i.indexOf(a);i.splice(b,1),0===i.length&&h.onCompleted()}))}catch(k){l(k).subscribe(b)}for(c=new o,g=j.getValues(),d=0,e=g.length;e>d;d++)f=g[d],f.subscribe(),c.add(f);return c})},c});