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);
@@ -693,30 +693,30 @@
693
693
  return RefCountDisposable;
694
694
  })();
695
695
 
696
- var ScheduledItem = Rx.internals.ScheduledItem = function (scheduler, state, action, dueTime, comparer) {
697
- this.scheduler = scheduler;
698
- this.state = state;
699
- this.action = action;
700
- this.dueTime = dueTime;
701
- this.comparer = comparer || defaultSubComparer;
702
- this.disposable = new SingleAssignmentDisposable();
703
- }
696
+ var ScheduledItem = Rx.internals.ScheduledItem = function (scheduler, state, action, dueTime, comparer) {
697
+ this.scheduler = scheduler;
698
+ this.state = state;
699
+ this.action = action;
700
+ this.dueTime = dueTime;
701
+ this.comparer = comparer || defaultSubComparer;
702
+ this.disposable = new SingleAssignmentDisposable();
703
+ }
704
704
 
705
- ScheduledItem.prototype.invoke = function () {
706
- this.disposable.setDisposable(this.invokeCore());
707
- };
705
+ ScheduledItem.prototype.invoke = function () {
706
+ this.disposable.setDisposable(this.invokeCore());
707
+ };
708
708
 
709
- ScheduledItem.prototype.compareTo = function (other) {
710
- return this.comparer(this.dueTime, other.dueTime);
711
- };
709
+ ScheduledItem.prototype.compareTo = function (other) {
710
+ return this.comparer(this.dueTime, other.dueTime);
711
+ };
712
712
 
713
- ScheduledItem.prototype.isCancelled = function () {
714
- return this.disposable.isDisposed;
715
- };
713
+ ScheduledItem.prototype.isCancelled = function () {
714
+ return this.disposable.isDisposed;
715
+ };
716
716
 
717
- ScheduledItem.prototype.invokeCore = function () {
718
- return this.action(this.scheduler, this.state);
719
- };
717
+ ScheduledItem.prototype.invokeCore = function () {
718
+ return this.action(this.scheduler, this.state);
719
+ };
720
720
 
721
721
  /** Provides a set of static properties to access commonly used schedulers. */
722
722
  var Scheduler = Rx.Scheduler = (function () {
@@ -728,54 +728,6 @@
728
728
  this._scheduleAbsolute = scheduleAbsolute;
729
729
  }
730
730
 
731
- function invokeRecImmediate(scheduler, pair) {
732
- var state = pair.first, action = pair.second, group = new CompositeDisposable(),
733
- recursiveAction = function (state1) {
734
- action(state1, function (state2) {
735
- var isAdded = false, isDone = false,
736
- d = scheduler.scheduleWithState(state2, function (scheduler1, state3) {
737
- if (isAdded) {
738
- group.remove(d);
739
- } else {
740
- isDone = true;
741
- }
742
- recursiveAction(state3);
743
- return disposableEmpty;
744
- });
745
- if (!isDone) {
746
- group.add(d);
747
- isAdded = true;
748
- }
749
- });
750
- };
751
- recursiveAction(state);
752
- return group;
753
- }
754
-
755
- function invokeRecDate(scheduler, pair, method) {
756
- var state = pair.first, action = pair.second, group = new CompositeDisposable(),
757
- recursiveAction = function (state1) {
758
- action(state1, function (state2, dueTime1) {
759
- var isAdded = false, isDone = false,
760
- d = scheduler[method].call(scheduler, state2, dueTime1, function (scheduler1, state3) {
761
- if (isAdded) {
762
- group.remove(d);
763
- } else {
764
- isDone = true;
765
- }
766
- recursiveAction(state3);
767
- return disposableEmpty;
768
- });
769
- if (!isDone) {
770
- group.add(d);
771
- isAdded = true;
772
- }
773
- });
774
- };
775
- recursiveAction(state);
776
- return group;
777
- }
778
-
779
731
  function invokeAction(scheduler, action) {
780
732
  action();
781
733
  return disposableEmpty;
@@ -1095,34 +1047,34 @@
1095
1047
  return currentScheduler;
1096
1048
  }());
1097
1049
 
1098
- var SchedulePeriodicRecursive = Rx.internals.SchedulePeriodicRecursive = (function () {
1099
- function tick(command, recurse) {
1100
- recurse(0, this._period);
1101
- try {
1102
- this._state = this._action(this._state);
1103
- } catch (e) {
1104
- this._cancel.dispose();
1105
- throw e;
1106
- }
1107
- }
1050
+ var SchedulePeriodicRecursive = Rx.internals.SchedulePeriodicRecursive = (function () {
1051
+ function tick(command, recurse) {
1052
+ recurse(0, this._period);
1053
+ try {
1054
+ this._state = this._action(this._state);
1055
+ } catch (e) {
1056
+ this._cancel.dispose();
1057
+ throw e;
1058
+ }
1059
+ }
1108
1060
 
1109
- function SchedulePeriodicRecursive(scheduler, state, period, action) {
1110
- this._scheduler = scheduler;
1111
- this._state = state;
1112
- this._period = period;
1113
- this._action = action;
1114
- }
1061
+ function SchedulePeriodicRecursive(scheduler, state, period, action) {
1062
+ this._scheduler = scheduler;
1063
+ this._state = state;
1064
+ this._period = period;
1065
+ this._action = action;
1066
+ }
1115
1067
 
1116
- SchedulePeriodicRecursive.prototype.start = function () {
1117
- var d = new SingleAssignmentDisposable();
1118
- this._cancel = d;
1119
- d.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0, this._period, tick.bind(this)));
1068
+ SchedulePeriodicRecursive.prototype.start = function () {
1069
+ var d = new SingleAssignmentDisposable();
1070
+ this._cancel = d;
1071
+ d.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0, this._period, tick.bind(this)));
1120
1072
 
1121
- return d;
1122
- };
1073
+ return d;
1074
+ };
1123
1075
 
1124
- return SchedulePeriodicRecursive;
1125
- }());
1076
+ return SchedulePeriodicRecursive;
1077
+ }());
1126
1078
 
1127
1079
  var scheduleMethod, clearMethod = noop;
1128
1080
  var localTimer = (function () {
@@ -1360,14 +1312,14 @@
1360
1312
  function _acceptObservable(observer) { return observer.onError(this.exception); }
1361
1313
  function toString () { return 'OnError(' + this.exception + ')'; }
1362
1314
 
1363
- return function (exception) {
1315
+ return function (e) {
1364
1316
  var notification = new Notification('E');
1365
- notification.exception = exception;
1317
+ notification.exception = e;
1366
1318
  notification._accept = _accept;
1367
1319
  notification._acceptObservable = _acceptObservable;
1368
1320
  notification.toString = toString;
1369
1321
  return notification;
1370
- };
1322
+ };
1371
1323
  }());
1372
1324
 
1373
1325
  /**
@@ -1376,17 +1328,17 @@
1376
1328
  */
1377
1329
  var notificationCreateOnCompleted = Notification.createOnCompleted = (function () {
1378
1330
 
1379
- function _accept (onNext, onError, onCompleted) { return onCompleted(); }
1380
- function _acceptObservable(observer) { return observer.onCompleted(); }
1381
- function toString () { return 'OnCompleted()'; }
1331
+ function _accept (onNext, onError, onCompleted) { return onCompleted(); }
1332
+ function _acceptObservable(observer) { return observer.onCompleted(); }
1333
+ function toString () { return 'OnCompleted()'; }
1382
1334
 
1383
- return function () {
1384
- var notification = new Notification('C');
1385
- notification._accept = _accept;
1386
- notification._acceptObservable = _acceptObservable;
1387
- notification.toString = toString;
1388
- return notification;
1389
- };
1335
+ return function () {
1336
+ var notification = new Notification('C');
1337
+ notification._accept = _accept;
1338
+ notification._acceptObservable = _acceptObservable;
1339
+ notification.toString = toString;
1340
+ return notification;
1341
+ };
1390
1342
  }());
1391
1343
 
1392
1344
  var Enumerator = Rx.internals.Enumerator = function (next) {
@@ -1936,7 +1888,7 @@
1936
1888
  * @param {Any} [thisArg] The context to use calling the mapFn if provided.
1937
1889
  * @param {Scheduler} [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread.
1938
1890
  */
1939
- Observable.from = function (iterable, mapFn, thisArg, scheduler) {
1891
+ var observableFrom = Observable.from = function (iterable, mapFn, thisArg, scheduler) {
1940
1892
  if (iterable == null) {
1941
1893
  throw new Error('iterable cannot be null.')
1942
1894
  }
@@ -1954,7 +1906,13 @@
1954
1906
  if (i < len || objIsIterable) {
1955
1907
  var result;
1956
1908
  if (objIsIterable) {
1957
- var next = it.next();
1909
+ var next;
1910
+ try {
1911
+ next = it.next();
1912
+ } catch (e) {
1913
+ observer.onError(e);
1914
+ return;
1915
+ }
1958
1916
  if (next.done) {
1959
1917
  observer.onCompleted();
1960
1918
  return;
@@ -1962,7 +1920,7 @@
1962
1920
 
1963
1921
  result = next.value;
1964
1922
  } else {
1965
- result = list[i];
1923
+ result = !!list.charAt ? list.charAt(i) : list[i];
1966
1924
  }
1967
1925
 
1968
1926
  if (mapFn && isCallable(mapFn)) {
@@ -2960,47 +2918,50 @@
2960
2918
  });
2961
2919
  };
2962
2920
 
2963
- function concatMap(source, selector, thisArg) {
2964
- return source.map(function (x, i) {
2965
- var result = selector.call(thisArg, x, i);
2966
- return isPromise(result) ? observableFromPromise(result) : result;
2967
- }).concatAll();
2968
- }
2921
+ function concatMap(source, selector, thisArg) {
2922
+ return source.map(function (x, i) {
2923
+ var result = selector.call(thisArg, x, i, source);
2924
+ isPromise(result) && (result = observableFromPromise(result));
2925
+ (Array.isArray(result) || isIterable(result)) && (result = observableFrom(result));
2926
+ return result;
2927
+ }).concatAll();
2928
+ }
2969
2929
 
2970
- /**
2971
- * One of the Following:
2972
- * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
2973
- *
2974
- * @example
2975
- * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); });
2976
- * Or:
2977
- * 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.
2978
- *
2979
- * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
2980
- * Or:
2981
- * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
2982
- *
2983
- * var res = source.concatMap(Rx.Observable.fromArray([1,2,3]));
2984
- * @param selector A transform function to apply to each element or an observable sequence to project each element from the
2985
- * source sequence onto which could be either an observable or Promise.
2986
- * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
2987
- * @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.
2988
- */
2989
- observableProto.selectConcat = observableProto.concatMap = function (selector, resultSelector, thisArg) {
2990
- if (resultSelector) {
2991
- return this.concatMap(function (x, i) {
2992
- var selectorResult = selector(x, i),
2993
- result = isPromise(selectorResult) ? observableFromPromise(selectorResult) : selectorResult;
2994
-
2995
- return result.map(function (y) {
2996
- return resultSelector(x, y, i);
2997
- });
2998
- });
2999
- }
3000
- return typeof selector === 'function' ?
3001
- concatMap(this, selector, thisArg) :
3002
- concatMap(this, function () { return selector; });
3003
- };
2930
+ /**
2931
+ * One of the Following:
2932
+ * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
2933
+ *
2934
+ * @example
2935
+ * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); });
2936
+ * Or:
2937
+ * 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.
2938
+ *
2939
+ * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
2940
+ * Or:
2941
+ * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
2942
+ *
2943
+ * var res = source.concatMap(Rx.Observable.fromArray([1,2,3]));
2944
+ * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the
2945
+ * source sequence onto which could be either an observable or Promise.
2946
+ * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
2947
+ * @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.
2948
+ */
2949
+ observableProto.selectConcat = observableProto.concatMap = function (selector, resultSelector, thisArg) {
2950
+ if (typeof selector === 'function' && typeof resultSelector === 'function') {
2951
+ return this.concatMap(function (x, i) {
2952
+ var selectorResult = selector(x, i);
2953
+ isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult));
2954
+ (Array.isArray(selectorResult) || isIterable(selectorResult)) && (selectorResult = observableFrom(selectorResult));
2955
+
2956
+ return selectorResult.map(function (y, i2) {
2957
+ return resultSelector(x, y, i, i2);
2958
+ });
2959
+ });
2960
+ }
2961
+ return typeof selector === 'function' ?
2962
+ concatMap(this, selector, thisArg) :
2963
+ concatMap(this, function () { return selector; });
2964
+ };
3004
2965
 
3005
2966
  /**
3006
2967
  * Projects each element of an observable sequence into a new form by incorporating the element's index.
@@ -3034,48 +2995,50 @@
3034
2995
  return this.map(function (x) { return x[prop]; });
3035
2996
  };
3036
2997
 
3037
- function flatMap(source, selector, thisArg) {
3038
- return source.map(function (x, i) {
3039
- var result = selector.call(thisArg, x, i);
3040
- return isPromise(result) ? observableFromPromise(result) : result;
3041
- }).mergeObservable();
3042
- }
2998
+ function flatMap(source, selector, thisArg) {
2999
+ return source.map(function (x, i) {
3000
+ var result = selector.call(thisArg, x, i, source);
3001
+ isPromise(result) && (result = observableFromPromise(result));
3002
+ (Array.isArray(result) || isIterable(result)) && (result = observableFrom(result));
3003
+ return result;
3004
+ }).mergeObservable();
3005
+ }
3043
3006
 
3044
- /**
3045
- * One of the Following:
3046
- * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
3047
- *
3048
- * @example
3049
- * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); });
3050
- * Or:
3051
- * 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.
3052
- *
3053
- * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
3054
- * Or:
3055
- * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
3056
- *
3057
- * var res = source.selectMany(Rx.Observable.fromArray([1,2,3]));
3058
- * @param selector A transform function to apply to each element or an observable sequence to project each element from the
3059
- * source sequence onto which could be either an observable or Promise.
3060
- * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
3061
- * @param {Any} [thisArg] Object to use as this when executing callback.
3062
- * @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.
3063
- */
3064
- observableProto.selectMany = observableProto.flatMap = function (selector, resultSelector, thisArg) {
3065
- if (resultSelector) {
3066
- return this.flatMap(function (x, i) {
3067
- var selectorResult = selector(x, i),
3068
- result = isPromise(selectorResult) ? observableFromPromise(selectorResult) : selectorResult;
3069
-
3070
- return result.map(function (y) {
3071
- return resultSelector(x, y, i);
3072
- });
3073
- }, thisArg);
3074
- }
3075
- return typeof selector === 'function' ?
3076
- flatMap(this, selector, thisArg) :
3077
- flatMap(this, function () { return selector; });
3078
- };
3007
+ /**
3008
+ * One of the Following:
3009
+ * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
3010
+ *
3011
+ * @example
3012
+ * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); });
3013
+ * Or:
3014
+ * 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.
3015
+ *
3016
+ * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
3017
+ * Or:
3018
+ * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
3019
+ *
3020
+ * var res = source.selectMany(Rx.Observable.fromArray([1,2,3]));
3021
+ * @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.
3022
+ * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
3023
+ * @param {Any} [thisArg] Object to use as this when executing callback.
3024
+ * @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.
3025
+ */
3026
+ observableProto.selectMany = observableProto.flatMap = function (selector, resultSelector, thisArg) {
3027
+ if (typeof selector === 'function' && typeof resultSelector === 'function') {
3028
+ return this.flatMap(function (x, i) {
3029
+ var selectorResult = selector(x, i);
3030
+ isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult));
3031
+ (Array.isArray(selectorResult) || isIterable(selectorResult)) && (selectorResult = observableFrom(selectorResult));
3032
+
3033
+ return selectorResult.map(function (y, i2) {
3034
+ return resultSelector(x, y, i, i2);
3035
+ });
3036
+ }, thisArg);
3037
+ }
3038
+ return typeof selector === 'function' ?
3039
+ flatMap(this, selector, thisArg) :
3040
+ flatMap(this, function () { return selector; });
3041
+ };
3079
3042
 
3080
3043
  /**
3081
3044
  * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then
@@ -3985,7 +3948,7 @@
3985
3948
  * @returns {Observable} The source sequence switching to the other sequence in case of a timeout.
3986
3949
  */
3987
3950
  observableProto.timeout = function (dueTime, other, scheduler) {
3988
- other || (other = observableThrow(new Error('Timeout')));
3951
+ (other == null || typeof other === 'string') && (other = observableThrow(new Error(other || 'Timeout')));
3989
3952
  isScheduler(scheduler) || (scheduler = timeoutScheduler);
3990
3953
 
3991
3954
  var source = this, schedulerMethod = dueTime instanceof Date ?
@@ -4389,115 +4352,41 @@
4389
4352
  return ControlledSubject;
4390
4353
  }(Observable));
4391
4354
 
4392
- /*
4393
- * Performs a exclusive waiting for the first to finish before subscribing to another observable.
4394
- * Observables that come in between subscriptions will be dropped on the floor.
4395
- * @returns {Observable} A exclusive observable with only the results that happen when subscribed.
4355
+ /**
4356
+ * Executes a transducer to transform the observable sequence
4357
+ * @param {Transducer} transducer A transducer to execute
4358
+ * @returns {Observable} An Observable sequence containing the results from the transducer.
4396
4359
  */
4397
- observableProto.exclusive = function () {
4398
- var sources = this;
4399
- return new AnonymousObservable(function (observer) {
4400
- var hasCurrent = false,
4401
- isStopped = false,
4402
- m = new SingleAssignmentDisposable(),
4403
- g = new CompositeDisposable();
4404
-
4405
- g.add(m);
4406
-
4407
- m.setDisposable(sources.subscribe(
4408
- function (innerSource) {
4409
- if (!hasCurrent) {
4410
- hasCurrent = true;
4411
-
4412
- isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
4413
-
4414
- var innerSubscription = new SingleAssignmentDisposable();
4415
- g.add(innerSubscription);
4360
+ observableProto.transduce = function(transducer) {
4361
+ var source = this;
4416
4362
 
4417
- innerSubscription.setDisposable(innerSource.subscribe(
4418
- observer.onNext.bind(observer),
4419
- observer.onError.bind(observer),
4420
- function () {
4421
- g.remove(innerSubscription);
4422
- hasCurrent = false;
4423
- if (isStopped && g.length === 1) {
4424
- observer.onCompleted();
4425
- }
4426
- }));
4427
- }
4363
+ function transformForObserver(observer) {
4364
+ return {
4365
+ init: function() {
4366
+ return observer;
4428
4367
  },
4429
- observer.onError.bind(observer),
4430
- function () {
4431
- isStopped = true;
4432
- if (!hasCurrent && g.length === 1) {
4433
- observer.onCompleted();
4434
- }
4435
- }));
4436
-
4437
- return g;
4438
- });
4439
- };
4440
-
4441
- /*
4442
- * Performs a exclusive map waiting for the first to finish before subscribing to another observable.
4443
- * Observables that come in between subscriptions will be dropped on the floor.
4444
- * @param {Function} selector Selector to invoke for every item in the current subscription.
4445
- * @param {Any} [thisArg] An optional context to invoke with the selector parameter.
4446
- * @returns {Observable} An exclusive observable with only the results that happen when subscribed.
4447
- */
4448
- observableProto.exclusiveMap = function (selector, thisArg) {
4449
- var sources = this;
4450
- return new AnonymousObservable(function (observer) {
4451
- var index = 0,
4452
- hasCurrent = false,
4453
- isStopped = true,
4454
- m = new SingleAssignmentDisposable(),
4455
- g = new CompositeDisposable();
4456
-
4457
- g.add(m);
4458
-
4459
- m.setDisposable(sources.subscribe(
4460
- function (innerSource) {
4461
-
4462
- if (!hasCurrent) {
4463
- hasCurrent = true;
4464
-
4465
- innerSubscription = new SingleAssignmentDisposable();
4466
- g.add(innerSubscription);
4467
-
4468
- isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
4469
-
4470
- innerSubscription.setDisposable(innerSource.subscribe(
4471
- function (x) {
4472
- var result;
4473
- try {
4474
- result = selector.call(thisArg, x, index++, innerSource);
4475
- } catch (e) {
4476
- observer.onError(e);
4477
- return;
4478
- }
4479
-
4480
- observer.onNext(result);
4481
- },
4482
- observer.onError.bind(observer),
4483
- function () {
4484
- g.remove(innerSubscription);
4485
- hasCurrent = false;
4486
-
4487
- if (isStopped && g.length === 1) {
4488
- observer.onCompleted();
4489
- }
4490
- }));
4491
- }
4368
+ step: function(obs, input) {
4369
+ return obs.onNext(input);
4492
4370
  },
4493
- observer.onError.bind(observer),
4494
- function () {
4495
- isStopped = true;
4496
- if (g.length === 1 && !hasCurrent) {
4497
- observer.onCompleted();
4371
+ result: function(obs) {
4372
+ return obs.onCompleted();
4373
+ }
4374
+ };
4375
+ }
4376
+
4377
+ return new AnonymousObservable(function(observer) {
4378
+ var xform = transducer(transformForObserver(observer));
4379
+ return source.subscribe(
4380
+ function(v) {
4381
+ try {
4382
+ xform.step(observer, v);
4383
+ } catch (e) {
4384
+ observer.onError(e);
4498
4385
  }
4499
- }));
4500
- return g;
4386
+ },
4387
+ observer.onError.bind(observer),
4388
+ function() { xform.result(observer); }
4389
+ );
4501
4390
  });
4502
4391
  };
4503
4392