rxjs-rails 2.3.11 → 2.3.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -307,7 +307,7 @@
307
307
  }
308
308
  }
309
309
  var size = 0;
310
- result = true;
310
+ var result = true;
311
311
 
312
312
  // add `a` and `b` to the stack of traversed objects
313
313
  stackA.push(a);
@@ -844,30 +844,30 @@ if (!Array.prototype.forEach) {
844
844
  return RefCountDisposable;
845
845
  })();
846
846
 
847
- var ScheduledItem = Rx.internals.ScheduledItem = function (scheduler, state, action, dueTime, comparer) {
848
- this.scheduler = scheduler;
849
- this.state = state;
850
- this.action = action;
851
- this.dueTime = dueTime;
852
- this.comparer = comparer || defaultSubComparer;
853
- this.disposable = new SingleAssignmentDisposable();
854
- }
847
+ var ScheduledItem = Rx.internals.ScheduledItem = function (scheduler, state, action, dueTime, comparer) {
848
+ this.scheduler = scheduler;
849
+ this.state = state;
850
+ this.action = action;
851
+ this.dueTime = dueTime;
852
+ this.comparer = comparer || defaultSubComparer;
853
+ this.disposable = new SingleAssignmentDisposable();
854
+ }
855
855
 
856
- ScheduledItem.prototype.invoke = function () {
857
- this.disposable.setDisposable(this.invokeCore());
858
- };
856
+ ScheduledItem.prototype.invoke = function () {
857
+ this.disposable.setDisposable(this.invokeCore());
858
+ };
859
859
 
860
- ScheduledItem.prototype.compareTo = function (other) {
861
- return this.comparer(this.dueTime, other.dueTime);
862
- };
860
+ ScheduledItem.prototype.compareTo = function (other) {
861
+ return this.comparer(this.dueTime, other.dueTime);
862
+ };
863
863
 
864
- ScheduledItem.prototype.isCancelled = function () {
865
- return this.disposable.isDisposed;
866
- };
864
+ ScheduledItem.prototype.isCancelled = function () {
865
+ return this.disposable.isDisposed;
866
+ };
867
867
 
868
- ScheduledItem.prototype.invokeCore = function () {
869
- return this.action(this.scheduler, this.state);
870
- };
868
+ ScheduledItem.prototype.invokeCore = function () {
869
+ return this.action(this.scheduler, this.state);
870
+ };
871
871
 
872
872
  /** Provides a set of static properties to access commonly used schedulers. */
873
873
  var Scheduler = Rx.Scheduler = (function () {
@@ -879,54 +879,6 @@ if (!Array.prototype.forEach) {
879
879
  this._scheduleAbsolute = scheduleAbsolute;
880
880
  }
881
881
 
882
- function invokeRecImmediate(scheduler, pair) {
883
- var state = pair.first, action = pair.second, group = new CompositeDisposable(),
884
- recursiveAction = function (state1) {
885
- action(state1, function (state2) {
886
- var isAdded = false, isDone = false,
887
- d = scheduler.scheduleWithState(state2, function (scheduler1, state3) {
888
- if (isAdded) {
889
- group.remove(d);
890
- } else {
891
- isDone = true;
892
- }
893
- recursiveAction(state3);
894
- return disposableEmpty;
895
- });
896
- if (!isDone) {
897
- group.add(d);
898
- isAdded = true;
899
- }
900
- });
901
- };
902
- recursiveAction(state);
903
- return group;
904
- }
905
-
906
- function invokeRecDate(scheduler, pair, method) {
907
- var state = pair.first, action = pair.second, group = new CompositeDisposable(),
908
- recursiveAction = function (state1) {
909
- action(state1, function (state2, dueTime1) {
910
- var isAdded = false, isDone = false,
911
- d = scheduler[method].call(scheduler, state2, dueTime1, function (scheduler1, state3) {
912
- if (isAdded) {
913
- group.remove(d);
914
- } else {
915
- isDone = true;
916
- }
917
- recursiveAction(state3);
918
- return disposableEmpty;
919
- });
920
- if (!isDone) {
921
- group.add(d);
922
- isAdded = true;
923
- }
924
- });
925
- };
926
- recursiveAction(state);
927
- return group;
928
- }
929
-
930
882
  function invokeAction(scheduler, action) {
931
883
  action();
932
884
  return disposableEmpty;
@@ -1246,34 +1198,34 @@ if (!Array.prototype.forEach) {
1246
1198
  return currentScheduler;
1247
1199
  }());
1248
1200
 
1249
- var SchedulePeriodicRecursive = Rx.internals.SchedulePeriodicRecursive = (function () {
1250
- function tick(command, recurse) {
1251
- recurse(0, this._period);
1252
- try {
1253
- this._state = this._action(this._state);
1254
- } catch (e) {
1255
- this._cancel.dispose();
1256
- throw e;
1257
- }
1258
- }
1201
+ var SchedulePeriodicRecursive = Rx.internals.SchedulePeriodicRecursive = (function () {
1202
+ function tick(command, recurse) {
1203
+ recurse(0, this._period);
1204
+ try {
1205
+ this._state = this._action(this._state);
1206
+ } catch (e) {
1207
+ this._cancel.dispose();
1208
+ throw e;
1209
+ }
1210
+ }
1259
1211
 
1260
- function SchedulePeriodicRecursive(scheduler, state, period, action) {
1261
- this._scheduler = scheduler;
1262
- this._state = state;
1263
- this._period = period;
1264
- this._action = action;
1265
- }
1212
+ function SchedulePeriodicRecursive(scheduler, state, period, action) {
1213
+ this._scheduler = scheduler;
1214
+ this._state = state;
1215
+ this._period = period;
1216
+ this._action = action;
1217
+ }
1266
1218
 
1267
- SchedulePeriodicRecursive.prototype.start = function () {
1268
- var d = new SingleAssignmentDisposable();
1269
- this._cancel = d;
1270
- d.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0, this._period, tick.bind(this)));
1219
+ SchedulePeriodicRecursive.prototype.start = function () {
1220
+ var d = new SingleAssignmentDisposable();
1221
+ this._cancel = d;
1222
+ d.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0, this._period, tick.bind(this)));
1271
1223
 
1272
- return d;
1273
- };
1224
+ return d;
1225
+ };
1274
1226
 
1275
- return SchedulePeriodicRecursive;
1276
- }());
1227
+ return SchedulePeriodicRecursive;
1228
+ }());
1277
1229
 
1278
1230
  var scheduleMethod, clearMethod = noop;
1279
1231
  var localTimer = (function () {
@@ -1511,14 +1463,14 @@ if (!Array.prototype.forEach) {
1511
1463
  function _acceptObservable(observer) { return observer.onError(this.exception); }
1512
1464
  function toString () { return 'OnError(' + this.exception + ')'; }
1513
1465
 
1514
- return function (exception) {
1466
+ return function (e) {
1515
1467
  var notification = new Notification('E');
1516
- notification.exception = exception;
1468
+ notification.exception = e;
1517
1469
  notification._accept = _accept;
1518
1470
  notification._acceptObservable = _acceptObservable;
1519
1471
  notification.toString = toString;
1520
1472
  return notification;
1521
- };
1473
+ };
1522
1474
  }());
1523
1475
 
1524
1476
  /**
@@ -1527,17 +1479,17 @@ if (!Array.prototype.forEach) {
1527
1479
  */
1528
1480
  var notificationCreateOnCompleted = Notification.createOnCompleted = (function () {
1529
1481
 
1530
- function _accept (onNext, onError, onCompleted) { return onCompleted(); }
1531
- function _acceptObservable(observer) { return observer.onCompleted(); }
1532
- function toString () { return 'OnCompleted()'; }
1482
+ function _accept (onNext, onError, onCompleted) { return onCompleted(); }
1483
+ function _acceptObservable(observer) { return observer.onCompleted(); }
1484
+ function toString () { return 'OnCompleted()'; }
1533
1485
 
1534
- return function () {
1535
- var notification = new Notification('C');
1536
- notification._accept = _accept;
1537
- notification._acceptObservable = _acceptObservable;
1538
- notification.toString = toString;
1539
- return notification;
1540
- };
1486
+ return function () {
1487
+ var notification = new Notification('C');
1488
+ notification._accept = _accept;
1489
+ notification._acceptObservable = _acceptObservable;
1490
+ notification.toString = toString;
1491
+ return notification;
1492
+ };
1541
1493
  }());
1542
1494
 
1543
1495
  var Enumerator = Rx.internals.Enumerator = function (next) {
@@ -2087,7 +2039,7 @@ if (!Array.prototype.forEach) {
2087
2039
  * @param {Any} [thisArg] The context to use calling the mapFn if provided.
2088
2040
  * @param {Scheduler} [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread.
2089
2041
  */
2090
- Observable.from = function (iterable, mapFn, thisArg, scheduler) {
2042
+ var observableFrom = Observable.from = function (iterable, mapFn, thisArg, scheduler) {
2091
2043
  if (iterable == null) {
2092
2044
  throw new Error('iterable cannot be null.')
2093
2045
  }
@@ -2105,7 +2057,13 @@ if (!Array.prototype.forEach) {
2105
2057
  if (i < len || objIsIterable) {
2106
2058
  var result;
2107
2059
  if (objIsIterable) {
2108
- var next = it.next();
2060
+ var next;
2061
+ try {
2062
+ next = it.next();
2063
+ } catch (e) {
2064
+ observer.onError(e);
2065
+ return;
2066
+ }
2109
2067
  if (next.done) {
2110
2068
  observer.onCompleted();
2111
2069
  return;
@@ -2113,7 +2071,7 @@ if (!Array.prototype.forEach) {
2113
2071
 
2114
2072
  result = next.value;
2115
2073
  } else {
2116
- result = list[i];
2074
+ result = !!list.charAt ? list.charAt(i) : list[i];
2117
2075
  }
2118
2076
 
2119
2077
  if (mapFn && isCallable(mapFn)) {
@@ -3111,47 +3069,50 @@ if (!Array.prototype.forEach) {
3111
3069
  });
3112
3070
  };
3113
3071
 
3114
- function concatMap(source, selector, thisArg) {
3115
- return source.map(function (x, i) {
3116
- var result = selector.call(thisArg, x, i);
3117
- return isPromise(result) ? observableFromPromise(result) : result;
3118
- }).concatAll();
3119
- }
3072
+ function concatMap(source, selector, thisArg) {
3073
+ return source.map(function (x, i) {
3074
+ var result = selector.call(thisArg, x, i, source);
3075
+ isPromise(result) && (result = observableFromPromise(result));
3076
+ (Array.isArray(result) || isIterable(result)) && (result = observableFrom(result));
3077
+ return result;
3078
+ }).concatAll();
3079
+ }
3120
3080
 
3121
- /**
3122
- * One of the Following:
3123
- * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
3124
- *
3125
- * @example
3126
- * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); });
3127
- * Or:
3128
- * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
3129
- *
3130
- * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
3131
- * Or:
3132
- * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
3133
- *
3134
- * var res = source.concatMap(Rx.Observable.fromArray([1,2,3]));
3135
- * @param selector A transform function to apply to each element or an observable sequence to project each element from the
3136
- * source sequence onto which could be either an observable or Promise.
3137
- * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
3138
- * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
3139
- */
3140
- observableProto.selectConcat = observableProto.concatMap = function (selector, resultSelector, thisArg) {
3141
- if (resultSelector) {
3142
- return this.concatMap(function (x, i) {
3143
- var selectorResult = selector(x, i),
3144
- result = isPromise(selectorResult) ? observableFromPromise(selectorResult) : selectorResult;
3145
-
3146
- return result.map(function (y) {
3147
- return resultSelector(x, y, i);
3148
- });
3149
- });
3150
- }
3151
- return typeof selector === 'function' ?
3152
- concatMap(this, selector, thisArg) :
3153
- concatMap(this, function () { return selector; });
3154
- };
3081
+ /**
3082
+ * One of the Following:
3083
+ * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
3084
+ *
3085
+ * @example
3086
+ * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); });
3087
+ * Or:
3088
+ * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
3089
+ *
3090
+ * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
3091
+ * Or:
3092
+ * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
3093
+ *
3094
+ * var res = source.concatMap(Rx.Observable.fromArray([1,2,3]));
3095
+ * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the
3096
+ * source sequence onto which could be either an observable or Promise.
3097
+ * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
3098
+ * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
3099
+ */
3100
+ observableProto.selectConcat = observableProto.concatMap = function (selector, resultSelector, thisArg) {
3101
+ if (typeof selector === 'function' && typeof resultSelector === 'function') {
3102
+ return this.concatMap(function (x, i) {
3103
+ var selectorResult = selector(x, i);
3104
+ isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult));
3105
+ (Array.isArray(selectorResult) || isIterable(selectorResult)) && (selectorResult = observableFrom(selectorResult));
3106
+
3107
+ return selectorResult.map(function (y, i2) {
3108
+ return resultSelector(x, y, i, i2);
3109
+ });
3110
+ });
3111
+ }
3112
+ return typeof selector === 'function' ?
3113
+ concatMap(this, selector, thisArg) :
3114
+ concatMap(this, function () { return selector; });
3115
+ };
3155
3116
 
3156
3117
  /**
3157
3118
  * Projects each element of an observable sequence into a new form by incorporating the element's index.
@@ -3185,48 +3146,50 @@ if (!Array.prototype.forEach) {
3185
3146
  return this.map(function (x) { return x[prop]; });
3186
3147
  };
3187
3148
 
3188
- function flatMap(source, selector, thisArg) {
3189
- return source.map(function (x, i) {
3190
- var result = selector.call(thisArg, x, i);
3191
- return isPromise(result) ? observableFromPromise(result) : result;
3192
- }).mergeObservable();
3193
- }
3149
+ function flatMap(source, selector, thisArg) {
3150
+ return source.map(function (x, i) {
3151
+ var result = selector.call(thisArg, x, i, source);
3152
+ isPromise(result) && (result = observableFromPromise(result));
3153
+ (Array.isArray(result) || isIterable(result)) && (result = observableFrom(result));
3154
+ return result;
3155
+ }).mergeObservable();
3156
+ }
3194
3157
 
3195
- /**
3196
- * One of the Following:
3197
- * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
3198
- *
3199
- * @example
3200
- * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); });
3201
- * Or:
3202
- * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
3203
- *
3204
- * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
3205
- * Or:
3206
- * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
3207
- *
3208
- * var res = source.selectMany(Rx.Observable.fromArray([1,2,3]));
3209
- * @param selector A transform function to apply to each element or an observable sequence to project each element from the
3210
- * source sequence onto which could be either an observable or Promise.
3211
- * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
3212
- * @param {Any} [thisArg] Object to use as this when executing callback.
3213
- * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
3214
- */
3215
- observableProto.selectMany = observableProto.flatMap = function (selector, resultSelector, thisArg) {
3216
- if (resultSelector) {
3217
- return this.flatMap(function (x, i) {
3218
- var selectorResult = selector(x, i),
3219
- result = isPromise(selectorResult) ? observableFromPromise(selectorResult) : selectorResult;
3220
-
3221
- return result.map(function (y) {
3222
- return resultSelector(x, y, i);
3223
- });
3224
- }, thisArg);
3225
- }
3226
- return typeof selector === 'function' ?
3227
- flatMap(this, selector, thisArg) :
3228
- flatMap(this, function () { return selector; });
3229
- };
3158
+ /**
3159
+ * One of the Following:
3160
+ * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
3161
+ *
3162
+ * @example
3163
+ * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); });
3164
+ * Or:
3165
+ * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
3166
+ *
3167
+ * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
3168
+ * Or:
3169
+ * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
3170
+ *
3171
+ * var res = source.selectMany(Rx.Observable.fromArray([1,2,3]));
3172
+ * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the source sequence onto which could be either an observable or Promise.
3173
+ * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
3174
+ * @param {Any} [thisArg] Object to use as this when executing callback.
3175
+ * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
3176
+ */
3177
+ observableProto.selectMany = observableProto.flatMap = function (selector, resultSelector, thisArg) {
3178
+ if (typeof selector === 'function' && typeof resultSelector === 'function') {
3179
+ return this.flatMap(function (x, i) {
3180
+ var selectorResult = selector(x, i);
3181
+ isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult));
3182
+ (Array.isArray(selectorResult) || isIterable(selectorResult)) && (selectorResult = observableFrom(selectorResult));
3183
+
3184
+ return selectorResult.map(function (y, i2) {
3185
+ return resultSelector(x, y, i, i2);
3186
+ });
3187
+ }, thisArg);
3188
+ }
3189
+ return typeof selector === 'function' ?
3190
+ flatMap(this, selector, thisArg) :
3191
+ flatMap(this, function () { return selector; });
3192
+ };
3230
3193
 
3231
3194
  /**
3232
3195
  * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then
@@ -4204,7 +4167,7 @@ if (!Array.prototype.forEach) {
4204
4167
  * @returns {Observable} The source sequence switching to the other sequence in case of a timeout.
4205
4168
  */
4206
4169
  observableProto.timeout = function (dueTime, other, scheduler) {
4207
- other || (other = observableThrow(new Error('Timeout')));
4170
+ (other == null || typeof other === 'string') && (other = observableThrow(new Error(other || 'Timeout')));
4208
4171
  isScheduler(scheduler) || (scheduler = timeoutScheduler);
4209
4172
 
4210
4173
  var source = this, schedulerMethod = dueTime instanceof Date ?
@@ -4608,115 +4571,41 @@ if (!Array.prototype.forEach) {
4608
4571
  return ControlledSubject;
4609
4572
  }(Observable));
4610
4573
 
4611
- /*
4612
- * Performs a exclusive waiting for the first to finish before subscribing to another observable.
4613
- * Observables that come in between subscriptions will be dropped on the floor.
4614
- * @returns {Observable} A exclusive observable with only the results that happen when subscribed.
4574
+ /**
4575
+ * Executes a transducer to transform the observable sequence
4576
+ * @param {Transducer} transducer A transducer to execute
4577
+ * @returns {Observable} An Observable sequence containing the results from the transducer.
4615
4578
  */
4616
- observableProto.exclusive = function () {
4617
- var sources = this;
4618
- return new AnonymousObservable(function (observer) {
4619
- var hasCurrent = false,
4620
- isStopped = false,
4621
- m = new SingleAssignmentDisposable(),
4622
- g = new CompositeDisposable();
4623
-
4624
- g.add(m);
4625
-
4626
- m.setDisposable(sources.subscribe(
4627
- function (innerSource) {
4628
- if (!hasCurrent) {
4629
- hasCurrent = true;
4630
-
4631
- isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
4632
-
4633
- var innerSubscription = new SingleAssignmentDisposable();
4634
- g.add(innerSubscription);
4579
+ observableProto.transduce = function(transducer) {
4580
+ var source = this;
4635
4581
 
4636
- innerSubscription.setDisposable(innerSource.subscribe(
4637
- observer.onNext.bind(observer),
4638
- observer.onError.bind(observer),
4639
- function () {
4640
- g.remove(innerSubscription);
4641
- hasCurrent = false;
4642
- if (isStopped && g.length === 1) {
4643
- observer.onCompleted();
4644
- }
4645
- }));
4646
- }
4582
+ function transformForObserver(observer) {
4583
+ return {
4584
+ init: function() {
4585
+ return observer;
4647
4586
  },
4648
- observer.onError.bind(observer),
4649
- function () {
4650
- isStopped = true;
4651
- if (!hasCurrent && g.length === 1) {
4652
- observer.onCompleted();
4653
- }
4654
- }));
4655
-
4656
- return g;
4657
- });
4658
- };
4659
-
4660
- /*
4661
- * Performs a exclusive map waiting for the first to finish before subscribing to another observable.
4662
- * Observables that come in between subscriptions will be dropped on the floor.
4663
- * @param {Function} selector Selector to invoke for every item in the current subscription.
4664
- * @param {Any} [thisArg] An optional context to invoke with the selector parameter.
4665
- * @returns {Observable} An exclusive observable with only the results that happen when subscribed.
4666
- */
4667
- observableProto.exclusiveMap = function (selector, thisArg) {
4668
- var sources = this;
4669
- return new AnonymousObservable(function (observer) {
4670
- var index = 0,
4671
- hasCurrent = false,
4672
- isStopped = true,
4673
- m = new SingleAssignmentDisposable(),
4674
- g = new CompositeDisposable();
4675
-
4676
- g.add(m);
4677
-
4678
- m.setDisposable(sources.subscribe(
4679
- function (innerSource) {
4680
-
4681
- if (!hasCurrent) {
4682
- hasCurrent = true;
4683
-
4684
- innerSubscription = new SingleAssignmentDisposable();
4685
- g.add(innerSubscription);
4686
-
4687
- isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
4688
-
4689
- innerSubscription.setDisposable(innerSource.subscribe(
4690
- function (x) {
4691
- var result;
4692
- try {
4693
- result = selector.call(thisArg, x, index++, innerSource);
4694
- } catch (e) {
4695
- observer.onError(e);
4696
- return;
4697
- }
4698
-
4699
- observer.onNext(result);
4700
- },
4701
- observer.onError.bind(observer),
4702
- function () {
4703
- g.remove(innerSubscription);
4704
- hasCurrent = false;
4705
-
4706
- if (isStopped && g.length === 1) {
4707
- observer.onCompleted();
4708
- }
4709
- }));
4710
- }
4587
+ step: function(obs, input) {
4588
+ return obs.onNext(input);
4711
4589
  },
4712
- observer.onError.bind(observer),
4713
- function () {
4714
- isStopped = true;
4715
- if (g.length === 1 && !hasCurrent) {
4716
- observer.onCompleted();
4590
+ result: function(obs) {
4591
+ return obs.onCompleted();
4592
+ }
4593
+ };
4594
+ }
4595
+
4596
+ return new AnonymousObservable(function(observer) {
4597
+ var xform = transducer(transformForObserver(observer));
4598
+ return source.subscribe(
4599
+ function(v) {
4600
+ try {
4601
+ xform.step(observer, v);
4602
+ } catch (e) {
4603
+ observer.onError(e);
4717
4604
  }
4718
- }));
4719
- return g;
4605
+ },
4606
+ observer.onError.bind(observer),
4607
+ function() { xform.result(observer); }
4608
+ );
4720
4609
  });
4721
4610
  };
4722
4611