rxjs-rails 2.2.20 → 2.2.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rxjs/rails/version.rb +1 -1
  3. data/vendor/assets/javascripts/rx.aggregates.js +38 -20
  4. data/vendor/assets/javascripts/rx.aggregates.min.js +1 -1
  5. data/vendor/assets/javascripts/rx.all.compat.js +9288 -0
  6. data/vendor/assets/javascripts/rx.all.compat.min.js +3 -0
  7. data/vendor/assets/javascripts/rx.all.js +9102 -0
  8. data/vendor/assets/javascripts/rx.all.min.js +3 -0
  9. data/vendor/assets/javascripts/rx.async.compat.js +5 -4
  10. data/vendor/assets/javascripts/rx.async.compat.min.js +1 -1
  11. data/vendor/assets/javascripts/rx.async.js +5 -4
  12. data/vendor/assets/javascripts/rx.async.min.js +1 -1
  13. data/vendor/assets/javascripts/rx.backpressure.js +24 -12
  14. data/vendor/assets/javascripts/rx.backpressure.min.js +1 -1
  15. data/vendor/assets/javascripts/rx.binding.js +85 -85
  16. data/vendor/assets/javascripts/rx.coincidence.js +59 -15
  17. data/vendor/assets/javascripts/rx.coincidence.min.js +1 -1
  18. data/vendor/assets/javascripts/rx.compat.js +809 -742
  19. data/vendor/assets/javascripts/rx.compat.min.js +2 -2
  20. data/vendor/assets/javascripts/rx.core.compat.js +2629 -0
  21. data/vendor/assets/javascripts/rx.core.compat.min.js +1 -0
  22. data/vendor/assets/javascripts/rx.core.js +2511 -0
  23. data/vendor/assets/javascripts/rx.core.min.js +1 -0
  24. data/vendor/assets/javascripts/rx.experimental.js +43 -43
  25. data/vendor/assets/javascripts/rx.joinpatterns.js +281 -281
  26. data/vendor/assets/javascripts/rx.js +792 -725
  27. data/vendor/assets/javascripts/rx.lite.compat.js +890 -758
  28. data/vendor/assets/javascripts/rx.lite.compat.min.js +2 -2
  29. data/vendor/assets/javascripts/rx.lite.extras.js +664 -0
  30. data/vendor/assets/javascripts/rx.lite.extras.min.js +1 -0
  31. data/vendor/assets/javascripts/rx.lite.js +890 -758
  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.js +166 -166
  35. data/vendor/assets/javascripts/rx.testing.min.js +1 -1
  36. data/vendor/assets/javascripts/rx.time.js +132 -131
  37. data/vendor/assets/javascripts/rx.time.min.js +1 -1
  38. data/vendor/assets/javascripts/rx.virtualtime.js +2 -2
  39. metadata +13 -4
  40. data/vendor/assets/javascripts/rx.node.js +0 -142
@@ -1,4 +1,4 @@
1
- // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
1
+ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
2
2
 
3
3
  ;(function (factory) {
4
4
  var objectTypes = {
@@ -33,23 +33,25 @@
33
33
  }
34
34
  }.call(this, function (root, exp, Rx, undefined) {
35
35
 
36
- // Refernces
37
- var Observable = Rx.Observable,
38
- observableProto = Observable.prototype,
39
- AnonymousObservable = Rx.AnonymousObservable,
40
- observableDefer = Observable.defer,
41
- observableEmpty = Observable.empty,
42
- observableNever = Observable.never,
43
- observableThrow = Observable.throwException,
44
- observableFromArray = Observable.fromArray,
45
- timeoutScheduler = Rx.Scheduler.timeout,
46
- SingleAssignmentDisposable = Rx.SingleAssignmentDisposable,
47
- SerialDisposable = Rx.SerialDisposable,
48
- CompositeDisposable = Rx.CompositeDisposable,
49
- RefCountDisposable = Rx.RefCountDisposable,
50
- Subject = Rx.Subject,
51
- addRef = Rx.internals.addRef,
52
- normalizeTime = Rx.Scheduler.normalize;
36
+ // Refernces
37
+ var Observable = Rx.Observable,
38
+ observableProto = Observable.prototype,
39
+ AnonymousObservable = Rx.AnonymousObservable,
40
+ observableDefer = Observable.defer,
41
+ observableEmpty = Observable.empty,
42
+ observableNever = Observable.never,
43
+ observableThrow = Observable.throwException,
44
+ observableFromArray = Observable.fromArray,
45
+ timeoutScheduler = Rx.Scheduler.timeout,
46
+ SingleAssignmentDisposable = Rx.SingleAssignmentDisposable,
47
+ SerialDisposable = Rx.SerialDisposable,
48
+ CompositeDisposable = Rx.CompositeDisposable,
49
+ RefCountDisposable = Rx.RefCountDisposable,
50
+ Subject = Rx.Subject,
51
+ addRef = Rx.internals.addRef,
52
+ normalizeTime = Rx.Scheduler.normalize,
53
+ isPromise = Rx.helpers.isPromise,
54
+ observableFromPromise = Observable.fromPromise;
53
55
 
54
56
  function observableTimerDate(dueTime, scheduler) {
55
57
  return new AnonymousObservable(function (observer) {
@@ -568,77 +570,71 @@
568
570
  return sampleObservable(this, intervalOrSampler);
569
571
  };
570
572
 
571
- /**
572
- * Returns the source observable sequence or the other observable sequence if dueTime elapses.
573
- *
574
- * @example
575
- * 1 - res = source.timeout(new Date()); // As a date
576
- * 2 - res = source.timeout(5000); // 5 seconds
577
- * 3 - res = source.timeout(new Date(), Rx.Observable.returnValue(42)); // As a date and timeout observable
578
- * 4 - res = source.timeout(5000, Rx.Observable.returnValue(42)); // 5 seconds and timeout observable
579
- * 5 - res = source.timeout(new Date(), Rx.Observable.returnValue(42), Rx.Scheduler.timeout); // As a date and timeout observable
580
- * 6 - res = source.timeout(5000, Rx.Observable.returnValue(42), Rx.Scheduler.timeout); // 5 seconds and timeout observable
581
- *
582
- * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) when a timeout occurs.
583
- * @param {Observable} [other] Sequence to return in case of a timeout. If not specified, a timeout error throwing sequence will be used.
584
- * @param {Scheduler} [scheduler] Scheduler to run the timeout timers on. If not specified, the timeout scheduler is used.
585
- * @returns {Observable} The source sequence switching to the other sequence in case of a timeout.
586
- */
587
- observableProto.timeout = function (dueTime, other, scheduler) {
588
- var schedulerMethod, source = this;
589
- other || (other = observableThrow(new Error('Timeout')));
590
- scheduler || (scheduler = timeoutScheduler);
591
- if (dueTime instanceof Date) {
592
- schedulerMethod = function (dt, action) {
593
- scheduler.scheduleWithAbsolute(dt, action);
594
- };
595
- } else {
596
- schedulerMethod = function (dt, action) {
597
- scheduler.scheduleWithRelative(dt, action);
598
- };
573
+ /**
574
+ * Returns the source observable sequence or the other observable sequence if dueTime elapses.
575
+ *
576
+ * @example
577
+ * 1 - res = source.timeout(new Date()); // As a date
578
+ * 2 - res = source.timeout(5000); // 5 seconds
579
+ * 3 - res = source.timeout(new Date(), Rx.Observable.returnValue(42)); // As a date and timeout observable
580
+ * 4 - res = source.timeout(5000, Rx.Observable.returnValue(42)); // 5 seconds and timeout observable
581
+ * 5 - res = source.timeout(new Date(), Rx.Observable.returnValue(42), Rx.Scheduler.timeout); // As a date and timeout observable
582
+ * 6 - res = source.timeout(5000, Rx.Observable.returnValue(42), Rx.Scheduler.timeout); // 5 seconds and timeout observable
583
+ *
584
+ * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) when a timeout occurs.
585
+ * @param {Observable} [other] Sequence to return in case of a timeout. If not specified, a timeout error throwing sequence will be used.
586
+ * @param {Scheduler} [scheduler] Scheduler to run the timeout timers on. If not specified, the timeout scheduler is used.
587
+ * @returns {Observable} The source sequence switching to the other sequence in case of a timeout.
588
+ */
589
+ observableProto.timeout = function (dueTime, other, scheduler) {
590
+ other || (other = observableThrow(new Error('Timeout')));
591
+ scheduler || (scheduler = timeoutScheduler);
592
+
593
+ var source = this, schedulerMethod = dueTime instanceof Date ?
594
+ 'scheduleWithAbsolute' :
595
+ 'scheduleWithRelative';
596
+
597
+ return new AnonymousObservable(function (observer) {
598
+ var id = 0,
599
+ original = new SingleAssignmentDisposable(),
600
+ subscription = new SerialDisposable(),
601
+ switched = false,
602
+ timer = new SerialDisposable();
603
+
604
+ subscription.setDisposable(original);
605
+
606
+ var createTimer = function () {
607
+ var myId = id;
608
+ timer.setDisposable(scheduler[schedulerMethod](dueTime, function () {
609
+ if (id === myId) {
610
+ isPromise(other) && (other = observableFromPromise(other));
611
+ subscription.setDisposable(other.subscribe(observer));
612
+ }
613
+ }));
614
+ };
615
+
616
+ createTimer();
617
+
618
+ original.setDisposable(source.subscribe(function (x) {
619
+ if (!switched) {
620
+ id++;
621
+ observer.onNext(x);
622
+ createTimer();
599
623
  }
600
- return new AnonymousObservable(function (observer) {
601
- var createTimer,
602
- id = 0,
603
- original = new SingleAssignmentDisposable(),
604
- subscription = new SerialDisposable(),
605
- switched = false,
606
- timer = new SerialDisposable();
607
- subscription.setDisposable(original);
608
- createTimer = function () {
609
- var myId = id;
610
- timer.setDisposable(schedulerMethod(dueTime, function () {
611
- switched = id === myId;
612
- var timerWins = switched;
613
- if (timerWins) {
614
- subscription.setDisposable(other.subscribe(observer));
615
- }
616
- }));
617
- };
618
- createTimer();
619
- original.setDisposable(source.subscribe(function (x) {
620
- var onNextWins = !switched;
621
- if (onNextWins) {
622
- id++;
623
- observer.onNext(x);
624
- createTimer();
625
- }
626
- }, function (e) {
627
- var onErrorWins = !switched;
628
- if (onErrorWins) {
629
- id++;
630
- observer.onError(e);
631
- }
632
- }, function () {
633
- var onCompletedWins = !switched;
634
- if (onCompletedWins) {
635
- id++;
636
- observer.onCompleted();
637
- }
638
- }));
639
- return new CompositeDisposable(subscription, timer);
640
- });
641
- };
624
+ }, function (e) {
625
+ if (!switched) {
626
+ id++;
627
+ observer.onError(e);
628
+ }
629
+ }, function () {
630
+ if (!switched) {
631
+ id++;
632
+ observer.onCompleted();
633
+ }
634
+ }));
635
+ return new CompositeDisposable(subscription, timer);
636
+ });
637
+ };
642
638
 
643
639
  /**
644
640
  * Generates an observable sequence by iterating a state from an initial state until the condition fails.
@@ -1116,50 +1112,55 @@
1116
1112
  });
1117
1113
  };
1118
1114
 
1119
- /**
1120
- * Skips elements from the observable source sequence until the specified start time, using the specified scheduler to run timers.
1121
- * Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the start time>.
1122
- *
1123
- * @examples
1124
- * 1 - res = source.skipUntilWithTime(new Date(), [optional scheduler]);
1125
- * @param startTime Time to start taking elements from the source sequence. If this value is less than or equal to Date(), no elements will be skipped.
1126
- * @param scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.
1127
- * @returns {Observable} An observable sequence with the elements skipped until the specified start time.
1128
- */
1129
- observableProto.skipUntilWithTime = function (startTime, scheduler) {
1130
- scheduler || (scheduler = timeoutScheduler);
1131
- var source = this;
1132
- return new AnonymousObservable(function (observer) {
1133
- var open = false,
1134
- t = scheduler.scheduleWithAbsolute(startTime, function () { open = true; }),
1135
- d = source.subscribe(function (x) {
1136
- if (open) {
1137
- observer.onNext(x);
1138
- }
1139
- }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
1115
+ /**
1116
+ * Skips elements from the observable source sequence until the specified start time, using the specified scheduler to run timers.
1117
+ * Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the start time.
1118
+ *
1119
+ * @examples
1120
+ * 1 - res = source.skipUntilWithTime(new Date(), [optional scheduler]);
1121
+ * 2 - res = source.skipUntilWithTime(5000, [optional scheduler]);
1122
+ * @param startTime Time to start taking elements from the source sequence. If this value is less than or equal to Date(), no elements will be skipped.
1123
+ * @param scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.
1124
+ * @returns {Observable} An observable sequence with the elements skipped until the specified start time.
1125
+ */
1126
+ observableProto.skipUntilWithTime = function (startTime, scheduler) {
1127
+ scheduler || (scheduler = timeoutScheduler);
1128
+ var source = this, schedulerMethod = startTime instanceof Date ?
1129
+ 'scheduleWithAbsolute' :
1130
+ 'scheduleWithRelative';
1131
+ return new AnonymousObservable(function (observer) {
1132
+ var open = false;
1140
1133
 
1141
- return new CompositeDisposable(t, d);
1142
- });
1143
- };
1134
+ return new CompositeDisposable(
1135
+ scheduler[schedulerMethod](startTime, function () { open = true; }),
1136
+ source.subscribe(
1137
+ function (x) { open && observer.onNext(x); },
1138
+ observer.onError.bind(observer),
1139
+ observer.onCompleted.bind(observer)));
1140
+ });
1141
+ };
1144
1142
 
1145
- /**
1146
- * Takes elements for the specified duration until the specified end time, using the specified scheduler to run timers.
1147
- *
1148
- * @example
1149
- * 1 - res = source.takeUntilWithTime(new Date(), [optional scheduler]);
1150
- * @param {Number} endTime Time to stop taking elements from the source sequence. If this value is less than or equal to new Date(), the result stream will complete immediately.
1151
- * @param {Scheduler} scheduler Scheduler to run the timer on.
1152
- * @returns {Observable} An observable sequence with the elements taken until the specified end time.
1153
- */
1154
- observableProto.takeUntilWithTime = function (endTime, scheduler) {
1155
- scheduler || (scheduler = timeoutScheduler);
1156
- var source = this;
1157
- return new AnonymousObservable(function (observer) {
1158
- return new CompositeDisposable(scheduler.scheduleWithAbsolute(endTime, function () {
1159
- observer.onCompleted();
1160
- }), source.subscribe(observer));
1161
- });
1162
- };
1143
+ /**
1144
+ * Takes elements for the specified duration until the specified end time, using the specified scheduler to run timers.
1145
+ *
1146
+ * @example
1147
+ * 1 - res = source.takeUntilWithTime(new Date(), [optional scheduler]);
1148
+ * 2 - res = source.takeUntilWithTime(5000, [optional scheduler]);
1149
+ * @param {Number | Date} endTime Time to stop taking elements from the source sequence. If this value is less than or equal to new Date(), the result stream will complete immediately.
1150
+ * @param {Scheduler} scheduler Scheduler to run the timer on.
1151
+ * @returns {Observable} An observable sequence with the elements taken until the specified end time.
1152
+ */
1153
+ observableProto.takeUntilWithTime = function (endTime, scheduler) {
1154
+ scheduler || (scheduler = timeoutScheduler);
1155
+ var source = this, schedulerMethod = endTime instanceof Date ?
1156
+ 'scheduleWithAbsolute' :
1157
+ 'scheduleWithRelative';
1158
+ return new AnonymousObservable(function (observer) {
1159
+ return new CompositeDisposable(scheduler[schedulerMethod](endTime, function () {
1160
+ observer.onCompleted();
1161
+ }), source.subscribe(observer));
1162
+ });
1163
+ };
1163
1164
 
1164
- return Rx;
1165
+ return Rx;
1165
1166
  }));
@@ -1 +1 @@
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 new n(function(c){return b.scheduleWithAbsolute(a,function(){c.onNext(0),c.onCompleted()})})}function f(a,b,c){var d=A(b);return new n(function(b){var e=0,f=a;return c.scheduleRecursiveWithAbsolute(f,function(a){var g;d>0&&(g=c.now(),f+=d,g>=f&&(f=g+d)),b.onNext(e++),a(f)})})}function g(a,b){var c=A(a);return new n(function(a){return b.scheduleWithRelative(c,function(){a.onNext(0),a.onCompleted()})})}function h(a,b,c){return a===b?new n(function(a){return c.schedulePeriodicWithState(0,b,function(b){return a.onNext(b),b+1})}):o(function(){return f(c.now()+a,b,c)})}function i(a,b){var c=this;return new n(function(d){var e,f=!1,g=new v,h=null,i=[],j=!1;return e=c.materialize().timestamp(b).subscribe(function(c){var e,k;"E"===c.value.kind?(i=[],i.push(c),h=c.value.exception,k=!j):(i.push({value:c.value,timestamp:c.timestamp+a}),k=!f,f=!0),k&&(null!==h?d.onError(h):(e=new u,g.setDisposable(e),e.setDisposable(b.scheduleRecursiveWithRelative(a,function(a){var c,e,g,k;if(null===h){j=!0;do g=null,i.length>0&&i[0].timestamp-b.now()<=0&&(g=i.shift().value),null!==g&&g.accept(d);while(null!==g);k=!1,e=0,i.length>0?(k=!0,e=Math.max(0,i[0].timestamp-b.now())):f=!1,c=h,j=!1,null!==c?d.onError(c):k&&a(e)}}))))}),new w(e,g)})}function j(a,b){var c=this;return o(function(){var d=a-b.now();return i.call(c,d,b)})}function k(a,b){return new n(function(c){function d(){g&&(g=!1,c.onNext(f)),e&&c.onCompleted()}var e,f,g;return new w(a.subscribe(function(a){g=!0,f=a},c.onError.bind(c),function(){e=!0}),b.subscribe(d,c.onError.bind(c),d))})}var l=c.Observable,m=l.prototype,n=c.AnonymousObservable,o=l.defer,p=l.empty,q=l.never,r=l.throwException,s=l.fromArray,t=c.Scheduler.timeout,u=c.SingleAssignmentDisposable,v=c.SerialDisposable,w=c.CompositeDisposable,x=c.RefCountDisposable,y=c.Subject,z=c.internals.addRef,A=c.Scheduler.normalize,B=l.interval=function(a,b){return b||(b=t),h(a,a,b)},C=l.timer=function(a,b,c){var i;return c||(c=t),b!==d&&"number"==typeof b?i=b:b!==d&&"object"==typeof b&&(c=b),a instanceof Date&&i===d?e(a.getTime(),c):a instanceof Date&&i!==d?(i=b,f(a.getTime(),i,c)):i===d?g(a,c):h(a,i,c)};return m.delay=function(a,b){return b||(b=t),a instanceof Date?j.call(this,a.getTime(),b):i.call(this,a,b)},m.throttle=function(a,b){b||(b=t);return this.throttleWithSelector(function(){return C(a,b)})},m.windowWithTime=function(a,b,c){var e,f=this;return b===d&&(e=a),c===d&&(c=t),"number"==typeof b?e=b:"object"==typeof b&&(e=a,c=b),new n(function(b){function d(){var a=new u,f=!1,g=!1;l.setDisposable(a),j===i?(f=!0,g=!0):i>j?f=!0:g=!0;var n=f?j:i,o=n-m;m=n,f&&(j+=e),g&&(i+=e),a.setDisposable(c.scheduleWithRelative(o,function(){var a;g&&(a=new y,k.push(a),b.onNext(z(a,h))),f&&(a=k.shift(),a.onCompleted()),d()}))}var g,h,i=e,j=a,k=[],l=new v,m=0;return g=new w(l),h=new x(g),k.push(new y),b.onNext(z(k[0],h)),d(),g.add(f.subscribe(function(a){var b,c;for(b=0;b<k.length;b++)c=k[b],c.onNext(a)},function(a){var c,d;for(c=0;c<k.length;c++)d=k[c],d.onError(a);b.onError(a)},function(){var a,c;for(a=0;a<k.length;a++)c=k[a],c.onCompleted();b.onCompleted()})),h})},m.windowWithTimeOrCount=function(a,b,c){var d=this;return c||(c=t),new n(function(e){var f,g,h,i,j=0,k=new v,l=0;return g=new w(k),h=new x(g),f=function(b){var d=new u;k.setDisposable(d),d.setDisposable(c.scheduleWithRelative(a,function(){var a;b===l&&(j=0,a=++l,i.onCompleted(),i=new y,e.onNext(z(i,h)),f(a))}))},i=new y,e.onNext(z(i,h)),f(0),g.add(d.subscribe(function(a){var c=0,d=!1;i.onNext(a),j++,j===b&&(d=!0,j=0,c=++l,i.onCompleted(),i=new y,e.onNext(z(i,h))),d&&f(c)},function(a){i.onError(a),e.onError(a)},function(){i.onCompleted(),e.onCompleted()})),h})},m.bufferWithTime=function(){return this.windowWithTime.apply(this,arguments).selectMany(function(a){return a.toArray()})},m.bufferWithTimeOrCount=function(a,b,c){return this.windowWithTimeOrCount(a,b,c).selectMany(function(a){return a.toArray()})},m.timeInterval=function(a){var b=this;return a||(a=t),o(function(){var c=a.now();return b.select(function(b){var d=a.now(),e=d-c;return c=d,{value:b,interval:e}})})},m.timestamp=function(a){return a||(a=t),this.select(function(b){return{value:b,timestamp:a.now()}})},m.sample=function(a,b){return b||(b=t),"number"==typeof a?k(this,B(a,b)):k(this,a)},m.timeout=function(a,b,c){var d,e=this;return b||(b=r(new Error("Timeout"))),c||(c=t),d=a instanceof Date?function(a,b){c.scheduleWithAbsolute(a,b)}:function(a,b){c.scheduleWithRelative(a,b)},new n(function(c){var f,g=0,h=new u,i=new v,j=!1,k=new v;return i.setDisposable(h),f=function(){var e=g;k.setDisposable(d(a,function(){j=g===e;var a=j;a&&i.setDisposable(b.subscribe(c))}))},f(),h.setDisposable(e.subscribe(function(a){var b=!j;b&&(g++,c.onNext(a),f())},function(a){var b=!j;b&&(g++,c.onError(a))},function(){var a=!j;a&&(g++,c.onCompleted())})),new w(i,k)})},l.generateWithAbsoluteTime=function(a,b,c,d,e,f){return f||(f=t),new n(function(g){var h,i,j=!0,k=!1,l=a;return f.scheduleRecursiveWithAbsolute(f.now(),function(a){k&&g.onNext(h);try{j?j=!1:l=c(l),k=b(l),k&&(h=d(l),i=e(l))}catch(f){return void g.onError(f)}k?a(i):g.onCompleted()})})},l.generateWithRelativeTime=function(a,b,c,d,e,f){return f||(f=t),new n(function(g){var h,i,j=!0,k=!1,l=a;return f.scheduleRecursiveWithRelative(0,function(a){k&&g.onNext(h);try{j?j=!1:l=c(l),k=b(l),k&&(h=d(l),i=e(l))}catch(f){return void g.onError(f)}k?a(i):g.onCompleted()})})},m.delaySubscription=function(a,b){return b||(b=t),this.delayWithSelector(C(a,b),function(){return p()})},m.delayWithSelector=function(a,b){var c,d,e=this;return"function"==typeof a?d=a:(c=a,d=b),new n(function(a){var b=new w,f=!1,g=function(){f&&0===b.length&&a.onCompleted()},h=new v,i=function(){h.setDisposable(e.subscribe(function(c){var e;try{e=d(c)}catch(f){return void a.onError(f)}var h=new u;b.add(h),h.setDisposable(e.subscribe(function(){a.onNext(c),b.remove(h),g()},a.onError.bind(a),function(){a.onNext(c),b.remove(h),g()}))},a.onError.bind(a),function(){f=!0,h.dispose(),g()}))};return c?h.setDisposable(c.subscribe(function(){i()},a.onError.bind(a),function(){i()})):i(),new w(h,b)})},m.timeoutWithSelector=function(a,b,c){if(1===arguments.length){b=a;var a=q()}c||(c=r(new Error("Timeout")));var d=this;return new n(function(e){var f=new v,g=new v,h=new u;f.setDisposable(h);var i=0,j=!1,k=function(a){var b=i,d=function(){return i===b},h=new u;g.setDisposable(h),h.setDisposable(a.subscribe(function(){d()&&f.setDisposable(c.subscribe(e)),h.dispose()},function(a){d()&&e.onError(a)},function(){d()&&f.setDisposable(c.subscribe(e))}))};k(a);var l=function(){var a=!j;return a&&i++,a};return h.setDisposable(d.subscribe(function(a){if(l()){e.onNext(a);var c;try{c=b(a)}catch(d){return void e.onError(d)}k(c)}},function(a){l()&&e.onError(a)},function(){l()&&e.onCompleted()})),new w(f,g)})},m.throttleWithSelector=function(a){var b=this;return new n(function(c){var d,e=!1,f=new v,g=0,h=b.subscribe(function(b){var h;try{h=a(b)}catch(i){return void c.onError(i)}e=!0,d=b,g++;var j=g,k=new u;f.setDisposable(k),k.setDisposable(h.subscribe(function(){e&&g===j&&c.onNext(d),e=!1,k.dispose()},c.onError.bind(c),function(){e&&g===j&&c.onNext(d),e=!1,k.dispose()}))},function(a){f.dispose(),c.onError(a),e=!1,g++},function(){f.dispose(),e&&c.onNext(d),c.onCompleted(),e=!1,g++});return new w(h,f)})},m.skipLastWithTime=function(a,b){b||(b=t);var c=this;return new n(function(d){var e=[];return c.subscribe(function(c){var f=b.now();for(e.push({interval:f,value:c});e.length>0&&f-e[0].interval>=a;)d.onNext(e.shift().value)},d.onError.bind(d),function(){for(var c=b.now();e.length>0&&c-e[0].interval>=a;)d.onNext(e.shift().value);d.onCompleted()})})},m.takeLastWithTime=function(a,b,c){return this.takeLastBufferWithTime(a,b).selectMany(function(a){return s(a,c)})},m.takeLastBufferWithTime=function(a,b){var c=this;return b||(b=t),new n(function(d){var e=[];return c.subscribe(function(c){var d=b.now();for(e.push({interval:d,value:c});e.length>0&&d-e[0].interval>=a;)e.shift()},d.onError.bind(d),function(){for(var c=b.now(),f=[];e.length>0;){var g=e.shift();c-g.interval<=a&&f.push(g.value)}d.onNext(f),d.onCompleted()})})},m.takeWithTime=function(a,b){var c=this;return b||(b=t),new n(function(d){var e=b.scheduleWithRelative(a,function(){d.onCompleted()});return new w(e,c.subscribe(d))})},m.skipWithTime=function(a,b){var c=this;return b||(b=t),new n(function(d){var e=!1,f=b.scheduleWithRelative(a,function(){e=!0}),g=c.subscribe(function(a){e&&d.onNext(a)},d.onError.bind(d),d.onCompleted.bind(d));return new w(f,g)})},m.skipUntilWithTime=function(a,b){b||(b=t);var c=this;return new n(function(d){var e=!1,f=b.scheduleWithAbsolute(a,function(){e=!0}),g=c.subscribe(function(a){e&&d.onNext(a)},d.onError.bind(d),d.onCompleted.bind(d));return new w(f,g)})},m.takeUntilWithTime=function(a,b){b||(b=t);var c=this;return new n(function(d){return new w(b.scheduleWithAbsolute(a,function(){d.onCompleted()}),c.subscribe(d))})},c});
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 new n(function(c){return b.scheduleWithAbsolute(a,function(){c.onNext(0),c.onCompleted()})})}function f(a,b,c){var d=A(b);return new n(function(b){var e=0,f=a;return c.scheduleRecursiveWithAbsolute(f,function(a){var g;d>0&&(g=c.now(),f+=d,g>=f&&(f=g+d)),b.onNext(e++),a(f)})})}function g(a,b){var c=A(a);return new n(function(a){return b.scheduleWithRelative(c,function(){a.onNext(0),a.onCompleted()})})}function h(a,b,c){return a===b?new n(function(a){return c.schedulePeriodicWithState(0,b,function(b){return a.onNext(b),b+1})}):o(function(){return f(c.now()+a,b,c)})}function i(a,b){var c=this;return new n(function(d){var e,f=!1,g=new v,h=null,i=[],j=!1;return e=c.materialize().timestamp(b).subscribe(function(c){var e,k;"E"===c.value.kind?(i=[],i.push(c),h=c.value.exception,k=!j):(i.push({value:c.value,timestamp:c.timestamp+a}),k=!f,f=!0),k&&(null!==h?d.onError(h):(e=new u,g.setDisposable(e),e.setDisposable(b.scheduleRecursiveWithRelative(a,function(a){var c,e,g,k;if(null===h){j=!0;do g=null,i.length>0&&i[0].timestamp-b.now()<=0&&(g=i.shift().value),null!==g&&g.accept(d);while(null!==g);k=!1,e=0,i.length>0?(k=!0,e=Math.max(0,i[0].timestamp-b.now())):f=!1,c=h,j=!1,null!==c?d.onError(c):k&&a(e)}}))))}),new w(e,g)})}function j(a,b){var c=this;return o(function(){var d=a-b.now();return i.call(c,d,b)})}function k(a,b){return new n(function(c){function d(){g&&(g=!1,c.onNext(f)),e&&c.onCompleted()}var e,f,g;return new w(a.subscribe(function(a){g=!0,f=a},c.onError.bind(c),function(){e=!0}),b.subscribe(d,c.onError.bind(c),d))})}var l=c.Observable,m=l.prototype,n=c.AnonymousObservable,o=l.defer,p=l.empty,q=l.never,r=l.throwException,s=l.fromArray,t=c.Scheduler.timeout,u=c.SingleAssignmentDisposable,v=c.SerialDisposable,w=c.CompositeDisposable,x=c.RefCountDisposable,y=c.Subject,z=c.internals.addRef,A=c.Scheduler.normalize,B=c.helpers.isPromise,C=l.fromPromise,D=l.interval=function(a,b){return b||(b=t),h(a,a,b)},E=l.timer=function(a,b,c){var i;return c||(c=t),b!==d&&"number"==typeof b?i=b:b!==d&&"object"==typeof b&&(c=b),a instanceof Date&&i===d?e(a.getTime(),c):a instanceof Date&&i!==d?(i=b,f(a.getTime(),i,c)):i===d?g(a,c):h(a,i,c)};return m.delay=function(a,b){return b||(b=t),a instanceof Date?j.call(this,a.getTime(),b):i.call(this,a,b)},m.throttle=function(a,b){b||(b=t);return this.throttleWithSelector(function(){return E(a,b)})},m.windowWithTime=function(a,b,c){var e,f=this;return b===d&&(e=a),c===d&&(c=t),"number"==typeof b?e=b:"object"==typeof b&&(e=a,c=b),new n(function(b){function d(){var a=new u,f=!1,g=!1;l.setDisposable(a),j===i?(f=!0,g=!0):i>j?f=!0:g=!0;var n=f?j:i,o=n-m;m=n,f&&(j+=e),g&&(i+=e),a.setDisposable(c.scheduleWithRelative(o,function(){var a;g&&(a=new y,k.push(a),b.onNext(z(a,h))),f&&(a=k.shift(),a.onCompleted()),d()}))}var g,h,i=e,j=a,k=[],l=new v,m=0;return g=new w(l),h=new x(g),k.push(new y),b.onNext(z(k[0],h)),d(),g.add(f.subscribe(function(a){var b,c;for(b=0;b<k.length;b++)c=k[b],c.onNext(a)},function(a){var c,d;for(c=0;c<k.length;c++)d=k[c],d.onError(a);b.onError(a)},function(){var a,c;for(a=0;a<k.length;a++)c=k[a],c.onCompleted();b.onCompleted()})),h})},m.windowWithTimeOrCount=function(a,b,c){var d=this;return c||(c=t),new n(function(e){var f,g,h,i,j=0,k=new v,l=0;return g=new w(k),h=new x(g),f=function(b){var d=new u;k.setDisposable(d),d.setDisposable(c.scheduleWithRelative(a,function(){var a;b===l&&(j=0,a=++l,i.onCompleted(),i=new y,e.onNext(z(i,h)),f(a))}))},i=new y,e.onNext(z(i,h)),f(0),g.add(d.subscribe(function(a){var c=0,d=!1;i.onNext(a),j++,j===b&&(d=!0,j=0,c=++l,i.onCompleted(),i=new y,e.onNext(z(i,h))),d&&f(c)},function(a){i.onError(a),e.onError(a)},function(){i.onCompleted(),e.onCompleted()})),h})},m.bufferWithTime=function(){return this.windowWithTime.apply(this,arguments).selectMany(function(a){return a.toArray()})},m.bufferWithTimeOrCount=function(a,b,c){return this.windowWithTimeOrCount(a,b,c).selectMany(function(a){return a.toArray()})},m.timeInterval=function(a){var b=this;return a||(a=t),o(function(){var c=a.now();return b.select(function(b){var d=a.now(),e=d-c;return c=d,{value:b,interval:e}})})},m.timestamp=function(a){return a||(a=t),this.select(function(b){return{value:b,timestamp:a.now()}})},m.sample=function(a,b){return b||(b=t),"number"==typeof a?k(this,D(a,b)):k(this,a)},m.timeout=function(a,b,c){b||(b=r(new Error("Timeout"))),c||(c=t);var d=this,e=a instanceof Date?"scheduleWithAbsolute":"scheduleWithRelative";return new n(function(f){var g=0,h=new u,i=new v,j=!1,k=new v;i.setDisposable(h);var l=function(){var d=g;k.setDisposable(c[e](a,function(){g===d&&(B(b)&&(b=C(b)),i.setDisposable(b.subscribe(f)))}))};return l(),h.setDisposable(d.subscribe(function(a){j||(g++,f.onNext(a),l())},function(a){j||(g++,f.onError(a))},function(){j||(g++,f.onCompleted())})),new w(i,k)})},l.generateWithAbsoluteTime=function(a,b,c,d,e,f){return f||(f=t),new n(function(g){var h,i,j=!0,k=!1,l=a;return f.scheduleRecursiveWithAbsolute(f.now(),function(a){k&&g.onNext(h);try{j?j=!1:l=c(l),k=b(l),k&&(h=d(l),i=e(l))}catch(f){return void g.onError(f)}k?a(i):g.onCompleted()})})},l.generateWithRelativeTime=function(a,b,c,d,e,f){return f||(f=t),new n(function(g){var h,i,j=!0,k=!1,l=a;return f.scheduleRecursiveWithRelative(0,function(a){k&&g.onNext(h);try{j?j=!1:l=c(l),k=b(l),k&&(h=d(l),i=e(l))}catch(f){return void g.onError(f)}k?a(i):g.onCompleted()})})},m.delaySubscription=function(a,b){return b||(b=t),this.delayWithSelector(E(a,b),function(){return p()})},m.delayWithSelector=function(a,b){var c,d,e=this;return"function"==typeof a?d=a:(c=a,d=b),new n(function(a){var b=new w,f=!1,g=function(){f&&0===b.length&&a.onCompleted()},h=new v,i=function(){h.setDisposable(e.subscribe(function(c){var e;try{e=d(c)}catch(f){return void a.onError(f)}var h=new u;b.add(h),h.setDisposable(e.subscribe(function(){a.onNext(c),b.remove(h),g()},a.onError.bind(a),function(){a.onNext(c),b.remove(h),g()}))},a.onError.bind(a),function(){f=!0,h.dispose(),g()}))};return c?h.setDisposable(c.subscribe(function(){i()},a.onError.bind(a),function(){i()})):i(),new w(h,b)})},m.timeoutWithSelector=function(a,b,c){if(1===arguments.length){b=a;var a=q()}c||(c=r(new Error("Timeout")));var d=this;return new n(function(e){var f=new v,g=new v,h=new u;f.setDisposable(h);var i=0,j=!1,k=function(a){var b=i,d=function(){return i===b},h=new u;g.setDisposable(h),h.setDisposable(a.subscribe(function(){d()&&f.setDisposable(c.subscribe(e)),h.dispose()},function(a){d()&&e.onError(a)},function(){d()&&f.setDisposable(c.subscribe(e))}))};k(a);var l=function(){var a=!j;return a&&i++,a};return h.setDisposable(d.subscribe(function(a){if(l()){e.onNext(a);var c;try{c=b(a)}catch(d){return void e.onError(d)}k(c)}},function(a){l()&&e.onError(a)},function(){l()&&e.onCompleted()})),new w(f,g)})},m.throttleWithSelector=function(a){var b=this;return new n(function(c){var d,e=!1,f=new v,g=0,h=b.subscribe(function(b){var h;try{h=a(b)}catch(i){return void c.onError(i)}e=!0,d=b,g++;var j=g,k=new u;f.setDisposable(k),k.setDisposable(h.subscribe(function(){e&&g===j&&c.onNext(d),e=!1,k.dispose()},c.onError.bind(c),function(){e&&g===j&&c.onNext(d),e=!1,k.dispose()}))},function(a){f.dispose(),c.onError(a),e=!1,g++},function(){f.dispose(),e&&c.onNext(d),c.onCompleted(),e=!1,g++});return new w(h,f)})},m.skipLastWithTime=function(a,b){b||(b=t);var c=this;return new n(function(d){var e=[];return c.subscribe(function(c){var f=b.now();for(e.push({interval:f,value:c});e.length>0&&f-e[0].interval>=a;)d.onNext(e.shift().value)},d.onError.bind(d),function(){for(var c=b.now();e.length>0&&c-e[0].interval>=a;)d.onNext(e.shift().value);d.onCompleted()})})},m.takeLastWithTime=function(a,b,c){return this.takeLastBufferWithTime(a,b).selectMany(function(a){return s(a,c)})},m.takeLastBufferWithTime=function(a,b){var c=this;return b||(b=t),new n(function(d){var e=[];return c.subscribe(function(c){var d=b.now();for(e.push({interval:d,value:c});e.length>0&&d-e[0].interval>=a;)e.shift()},d.onError.bind(d),function(){for(var c=b.now(),f=[];e.length>0;){var g=e.shift();c-g.interval<=a&&f.push(g.value)}d.onNext(f),d.onCompleted()})})},m.takeWithTime=function(a,b){var c=this;return b||(b=t),new n(function(d){var e=b.scheduleWithRelative(a,function(){d.onCompleted()});return new w(e,c.subscribe(d))})},m.skipWithTime=function(a,b){var c=this;return b||(b=t),new n(function(d){var e=!1,f=b.scheduleWithRelative(a,function(){e=!0}),g=c.subscribe(function(a){e&&d.onNext(a)},d.onError.bind(d),d.onCompleted.bind(d));return new w(f,g)})},m.skipUntilWithTime=function(a,b){b||(b=t);var c=this,d=a instanceof Date?"scheduleWithAbsolute":"scheduleWithRelative";return new n(function(e){var f=!1;return new w(b[d](a,function(){f=!0}),c.subscribe(function(a){f&&e.onNext(a)},e.onError.bind(e),e.onCompleted.bind(e)))})},m.takeUntilWithTime=function(a,b){b||(b=t);var c=this,d=a instanceof Date?"scheduleWithAbsolute":"scheduleWithRelative";return new n(function(e){return new w(b[d](a,function(){e.onCompleted()}),c.subscribe(e))})},c});
@@ -1,4 +1,4 @@
1
- // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
1
+ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
2
2
 
3
3
  ;(function (factory) {
4
4
  var objectTypes = {
@@ -331,5 +331,5 @@
331
331
 
332
332
  return HistoricalScheduler;
333
333
  }(Rx.VirtualTimeScheduler));
334
- return Rx;
334
+ return Rx;
335
335
  }));
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rxjs-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.20
4
+ version: 2.2.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - jdeseno
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-14 00:00:00.000000000 Z
11
+ date: 2014-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -51,6 +51,10 @@ files:
51
51
  - rxjs_license.txt
52
52
  - vendor/assets/javascripts/rx.aggregates.js
53
53
  - vendor/assets/javascripts/rx.aggregates.min.js
54
+ - vendor/assets/javascripts/rx.all.compat.js
55
+ - vendor/assets/javascripts/rx.all.compat.min.js
56
+ - vendor/assets/javascripts/rx.all.js
57
+ - vendor/assets/javascripts/rx.all.min.js
54
58
  - vendor/assets/javascripts/rx.async.compat.js
55
59
  - vendor/assets/javascripts/rx.async.compat.min.js
56
60
  - vendor/assets/javascripts/rx.async.js
@@ -63,6 +67,10 @@ files:
63
67
  - vendor/assets/javascripts/rx.coincidence.min.js
64
68
  - vendor/assets/javascripts/rx.compat.js
65
69
  - vendor/assets/javascripts/rx.compat.min.js
70
+ - vendor/assets/javascripts/rx.core.compat.js
71
+ - vendor/assets/javascripts/rx.core.compat.min.js
72
+ - vendor/assets/javascripts/rx.core.js
73
+ - vendor/assets/javascripts/rx.core.min.js
66
74
  - vendor/assets/javascripts/rx.experimental.js
67
75
  - vendor/assets/javascripts/rx.experimental.min.js
68
76
  - vendor/assets/javascripts/rx.joinpatterns.js
@@ -70,10 +78,11 @@ files:
70
78
  - vendor/assets/javascripts/rx.js
71
79
  - vendor/assets/javascripts/rx.lite.compat.js
72
80
  - vendor/assets/javascripts/rx.lite.compat.min.js
81
+ - vendor/assets/javascripts/rx.lite.extras.js
82
+ - vendor/assets/javascripts/rx.lite.extras.min.js
73
83
  - vendor/assets/javascripts/rx.lite.js
74
84
  - vendor/assets/javascripts/rx.lite.min.js
75
85
  - vendor/assets/javascripts/rx.min.js
76
- - vendor/assets/javascripts/rx.node.js
77
86
  - vendor/assets/javascripts/rx.testing.js
78
87
  - vendor/assets/javascripts/rx.testing.min.js
79
88
  - vendor/assets/javascripts/rx.time.js
@@ -101,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
110
  version: 1.3.6
102
111
  requirements: []
103
112
  rubyforge_project: rxjs-rails
104
- rubygems_version: 2.2.0
113
+ rubygems_version: 2.2.2
105
114
  signing_key:
106
115
  specification_version: 4
107
116
  summary: Use RxJS with rails
@@ -1,142 +0,0 @@
1
- var Rx = require('./rx');
2
- require('./rx.aggregates');
3
- require('./rx.backpressure');
4
- require('./rx.async');
5
- require('./rx.binding');
6
- require('./rx.coincidence');
7
- require('./rx.experimental');
8
- require('./rx.joinpatterns');
9
- require('./rx.time');
10
- require('./rx.virtualtime');
11
- require('./rx.testing');
12
-
13
- // Add specific Node functions
14
- var EventEmitter = require('events').EventEmitter,
15
- Observable = Rx.Observable;
16
-
17
- Rx.Node = {
18
- /**
19
- * @deprecated Use Rx.Observable.fromCallback from rx.async.js instead.
20
- *
21
- * Converts a callback function to an observable sequence.
22
- *
23
- * @param {Function} func Function to convert to an asynchronous function.
24
- * @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout.
25
- * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
26
- * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.
27
- * @returns {Function} Asynchronous function.
28
- */
29
- fromCallback: function (func, scheduler, context, selector) {
30
- return Observable.fromCallback(func, scheduler, context, selector);
31
- },
32
-
33
- /**
34
- * @deprecated Use Rx.Observable.fromNodeCallback from rx.async.js instead.
35
- *
36
- * Converts a Node.js callback style function to an observable sequence. This must be in function (err, ...) format.
37
- *
38
- * @param {Function} func The function to call
39
- * @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout.
40
- * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.
41
- * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.
42
- * @returns {Function} An async function which when applied, returns an observable sequence with the callback arguments as an array.
43
- */
44
- fromNodeCallback: function (func, scheduler, context, selector) {
45
- return Observable.fromNodeCallback(func, scheduler, context, selector);
46
- },
47
-
48
- /**
49
- * @deprecated Use Rx.Observable.fromNodeCallback from rx.async.js instead.
50
- *
51
- * Handles an event from the given EventEmitter as an observable sequence.
52
- *
53
- * @param {EventEmitter} eventEmitter The EventEmitter to subscribe to the given event.
54
- * @param {String} eventName The event name to subscribe
55
- * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.
56
- * @returns {Observable} An observable sequence generated from the named event from the given EventEmitter. The data will be returned as an array of arguments to the handler.
57
- */
58
- fromEvent: function (eventEmitter, eventName, selector) {
59
- return Observable.fromEvent(eventEmitter, eventName, selector);
60
- },
61
-
62
- /**
63
- * Converts the given observable sequence to an event emitter with the given event name.
64
- * The errors are handled on the 'error' event and completion on the 'end' event.
65
- * @param {Observable} observable The observable sequence to convert to an EventEmitter.
66
- * @param {String} eventName The event name to emit onNext calls.
67
- * @returns {EventEmitter} An EventEmitter which emits the given eventName for each onNext call in addition to 'error' and 'end' events.
68
- * You must call publish in order to invoke the subscription on the Observable sequuence.
69
- */
70
- toEventEmitter: function (observable, eventName) {
71
- var e = new EventEmitter();
72
-
73
- // Used to publish the events from the observable
74
- e.publish = function () {
75
- e.subscription = observable.subscribe(
76
- function (x) {
77
- e.emit(eventName, x);
78
- },
79
- function (err) {
80
- e.emit('error', err);
81
- },
82
- function () {
83
- e.emit('end');
84
- });
85
- };
86
-
87
- return e;
88
- },
89
-
90
- /**
91
- * Converts a flowing stream to an Observable sequence.
92
- * @param {Stream} stream A stream to convert to a observable sequence.
93
- * @returns {Observable} An observable sequence which fires on each 'data' event as well as handling 'error' and 'end' events.
94
- */
95
- fromStream: function (stream) {
96
- return Observable.create(function (observer) {
97
- function dataHandler (data) {
98
- observer.onNext(data);
99
- }
100
-
101
- function errorHandler (err) {
102
- observer.onError(err);
103
- }
104
-
105
- function endHandler () {
106
- observer.onCompleted();
107
- }
108
-
109
- stream.addListener('data', dataHandler);
110
- stream.addListener('error', errorHandler);
111
- stream.addListener('end', endHandler);
112
-
113
- return function () {
114
- stream.removeListener('data', dataHandler);
115
- stream.removeListener('error', errorHandler);
116
- stream.removeListener('end', endHandler);
117
- };
118
- }).publish().refCount();
119
- },
120
-
121
- /**
122
- * Writes an observable sequence to a stream
123
- * @param {Observable} observable Observable sequence to write to a stream.
124
- * @param {Stream} stream The stream to write to.
125
- * @param {String} [encoding] The encoding of the item to write.
126
- * @returns {Disposable} The subscription handle.
127
- */
128
- writeToStream: function (observable, stream, encoding) {
129
- return observable.subscribe(
130
- function (x) {
131
- stream.write(String(x), encoding);
132
- },
133
- function (err) {
134
- stream.emit('error', err);
135
- }, function () {
136
- // Hack check because STDIO is not closable
137
- !stream._isStdio && stream.end();
138
- });
139
- }
140
- };
141
-
142
- module.exports = Rx;