@@ -2617,59 +2617,6 @@ var FlatMapObservable = Rx.FlatMapObservable = (function(__super__) {
2617
2617
return new CatchErrorObservable ( this ) ;
2618
2618
} ;
2619
2619
2620
- Enumerable . prototype . catchErrorWhen = function ( notificationHandler ) {
2621
- var sources = this ;
2622
- return new AnonymousObservable ( function ( o ) {
2623
- var exceptions = new Subject ( ) ,
2624
- notifier = new Subject ( ) ,
2625
- handled = notificationHandler ( exceptions ) ,
2626
- notificationDisposable = handled . subscribe ( notifier ) ;
2627
-
2628
- var e = sources [ $iterator$ ] ( ) ;
2629
-
2630
- var state = { isDisposed : false } ,
2631
- lastError ,
2632
- subscription = new SerialDisposable ( ) ;
2633
- var cancelable = currentThreadScheduler . scheduleRecursive ( null , function ( _ , self ) {
2634
- if ( state . isDisposed ) { return ; }
2635
- var currentItem = tryCatch ( e . next ) . call ( e ) ;
2636
- if ( currentItem === errorObj ) { return o . onError ( currentItem . e ) ; }
2637
-
2638
- if ( currentItem . done ) {
2639
- if ( lastError ) {
2640
- o . onError ( lastError ) ;
2641
- } else {
2642
- o . onCompleted ( ) ;
2643
- }
2644
- return ;
2645
- }
2646
-
2647
- // Check if promise
2648
- var currentValue = currentItem . value ;
2649
- isPromise ( currentValue ) && ( currentValue = observableFromPromise ( currentValue ) ) ;
2650
-
2651
- var outer = new SingleAssignmentDisposable ( ) ;
2652
- var inner = new SingleAssignmentDisposable ( ) ;
2653
- subscription . setDisposable ( new BinaryDisposable ( inner , outer ) ) ;
2654
- outer . setDisposable ( currentValue . subscribe (
2655
- function ( x ) { o . onNext ( x ) ; } ,
2656
- function ( exn ) {
2657
- inner . setDisposable ( notifier . subscribe ( self , function ( ex ) {
2658
- o . onError ( ex ) ;
2659
- } , function ( ) {
2660
- o . onCompleted ( ) ;
2661
- } ) ) ;
2662
-
2663
- exceptions . onNext ( exn ) ;
2664
- outer . dispose ( ) ;
2665
- } ,
2666
- function ( ) { o . onCompleted ( ) ; } ) ) ;
2667
- } ) ;
2668
-
2669
- return new NAryDisposable ( [ notificationDisposable , subscription , cancelable , new IsDisposedDisposable ( state ) ] ) ;
2670
- } ) ;
2671
- } ;
2672
-
2673
2620
var RepeatEnumerable = ( function ( __super__ ) {
2674
2621
inherits ( RepeatEnumerable , __super__ ) ;
2675
2622
function RepeatEnumerable ( v , c ) {
@@ -5124,19 +5071,184 @@ observableProto.zipIterable = function () {
5124
5071
return enumerableRepeat ( this , retryCount ) . catchError ( ) ;
5125
5072
} ;
5126
5073
5127
- /**
5128
- * Repeats the source observable sequence upon error each time the notifier emits or until it successfully terminates.
5129
- * if the notifier completes, the observable sequence completes.
5130
- *
5131
- * @example
5132
- * var timer = Observable.timer(500);
5133
- * var source = observable.retryWhen(timer);
5134
- * @param {Observable } [notifier] An observable that triggers the retries or completes the observable with onNext or onCompleted respectively.
5135
- * @returns {Observable } An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.
5136
- */
5074
+ function repeat ( value ) {
5075
+ return {
5076
+ '@@iterator' : function ( ) {
5077
+ return {
5078
+ next : function ( ) {
5079
+ return { done : false , value : value } ;
5080
+ }
5081
+ } ;
5082
+ }
5083
+ } ;
5084
+ }
5085
+
5086
+ var RetryWhenObservable = ( function ( __super__ ) {
5087
+ function createDisposable ( state ) {
5088
+ return {
5089
+ isDisposed : false ,
5090
+ dispose : function ( ) {
5091
+ if ( ! this . isDisposed ) {
5092
+ this . isDisposed = true ;
5093
+ state . isDisposed = true ;
5094
+ }
5095
+ }
5096
+ } ;
5097
+ }
5098
+
5099
+ function RetryWhenObservable ( source , notifier ) {
5100
+ this . source = source ;
5101
+ this . _notifier = notifier ;
5102
+ __super__ . call ( this ) ;
5103
+ }
5104
+
5105
+ inherits ( RetryWhenObservable , __super__ ) ;
5106
+
5107
+ RetryWhenObservable . prototype . subscribeCore = function ( o ) {
5108
+ var exceptions = new Subject ( ) ,
5109
+ notifier = new Subject ( ) ,
5110
+ handled = this . _notifier ( exceptions ) ,
5111
+ notificationDisposable = handled . subscribe ( notifier ) ;
5112
+
5113
+ var e = this . source [ '@@iterator' ] ( ) ;
5114
+
5115
+ var state = { isDisposed : false } ,
5116
+ lastError ,
5117
+ subscription = new SerialDisposable ( ) ;
5118
+ var cancelable = currentThreadScheduler . scheduleRecursive ( null , function ( _ , recurse ) {
5119
+ if ( state . isDisposed ) { return ; }
5120
+ var currentItem = e . next ( ) ;
5121
+
5122
+ if ( currentItem . done ) {
5123
+ if ( lastError ) {
5124
+ o . onError ( lastError ) ;
5125
+ } else {
5126
+ o . onCompleted ( ) ;
5127
+ }
5128
+ return ;
5129
+ }
5130
+
5131
+ // Check if promise
5132
+ var currentValue = currentItem . value ;
5133
+ isPromise ( currentValue ) && ( currentValue = observableFromPromise ( currentValue ) ) ;
5134
+
5135
+ var outer = new SingleAssignmentDisposable ( ) ;
5136
+ var inner = new SingleAssignmentDisposable ( ) ;
5137
+ subscription . setDisposable ( new BinaryDisposable ( inner , outer ) ) ;
5138
+ outer . setDisposable ( currentValue . subscribe (
5139
+ function ( x ) { o . onNext ( x ) ; } ,
5140
+ function ( exn ) {
5141
+ inner . setDisposable ( notifier . subscribe ( recurse , function ( ex ) {
5142
+ o . onError ( ex ) ;
5143
+ } , function ( ) {
5144
+ o . onCompleted ( ) ;
5145
+ } ) ) ;
5146
+
5147
+ exceptions . onNext ( exn ) ;
5148
+ outer . dispose ( ) ;
5149
+ } ,
5150
+ function ( ) { o . onCompleted ( ) ; } ) ) ;
5151
+ } ) ;
5152
+
5153
+ return new NAryDisposable ( [ notificationDisposable , subscription , cancelable , createDisposable ( state ) ] ) ;
5154
+ } ;
5155
+
5156
+ return RetryWhenObservable ;
5157
+ } ( ObservableBase ) ) ;
5158
+
5137
5159
observableProto . retryWhen = function ( notifier ) {
5138
- return enumerableRepeat ( this ) . catchErrorWhen ( notifier ) ;
5160
+ return new RetryWhenObservable ( repeat ( this ) , notifier ) ;
5139
5161
} ;
5162
+
5163
+ function repeat ( value ) {
5164
+ return {
5165
+ '@@iterator' : function ( ) {
5166
+ return {
5167
+ next : function ( ) {
5168
+ return { done : false , value : value } ;
5169
+ }
5170
+ } ;
5171
+ }
5172
+ } ;
5173
+ }
5174
+
5175
+ var RepeatWhenObservable = ( function ( __super__ ) {
5176
+ function createDisposable ( state ) {
5177
+ return {
5178
+ isDisposed : false ,
5179
+ dispose : function ( ) {
5180
+ if ( ! this . isDisposed ) {
5181
+ this . isDisposed = true ;
5182
+ state . isDisposed = true ;
5183
+ }
5184
+ }
5185
+ } ;
5186
+ }
5187
+
5188
+ function RepeatWhenObservable ( source , notifier ) {
5189
+ this . source = source ;
5190
+ this . _notifier = notifier ;
5191
+ __super__ . call ( this ) ;
5192
+ }
5193
+
5194
+ inherits ( RepeatWhenObservable , __super__ ) ;
5195
+
5196
+ RepeatWhenObservable . prototype . subscribeCore = function ( o ) {
5197
+ var completions = new Subject ( ) ,
5198
+ notifier = new Subject ( ) ,
5199
+ handled = this . _notifier ( completions ) ,
5200
+ notificationDisposable = handled . subscribe ( notifier ) ;
5201
+
5202
+ var e = this . source [ '@@iterator' ] ( ) ;
5203
+
5204
+ var state = { isDisposed : false } ,
5205
+ lastError ,
5206
+ subscription = new SerialDisposable ( ) ;
5207
+ var cancelable = currentThreadScheduler . scheduleRecursive ( null , function ( _ , recurse ) {
5208
+ if ( state . isDisposed ) { return ; }
5209
+ var currentItem = e . next ( ) ;
5210
+
5211
+ if ( currentItem . done ) {
5212
+ if ( lastError ) {
5213
+ o . onError ( lastError ) ;
5214
+ } else {
5215
+ o . onCompleted ( ) ;
5216
+ }
5217
+ return ;
5218
+ }
5219
+
5220
+ // Check if promise
5221
+ var currentValue = currentItem . value ;
5222
+ isPromise ( currentValue ) && ( currentValue = observableFromPromise ( currentValue ) ) ;
5223
+
5224
+ var outer = new SingleAssignmentDisposable ( ) ;
5225
+ var inner = new SingleAssignmentDisposable ( ) ;
5226
+ subscription . setDisposable ( new BinaryDisposable ( inner , outer ) ) ;
5227
+ outer . setDisposable ( currentValue . subscribe (
5228
+ function ( x ) { o . onNext ( x ) ; } ,
5229
+ function ( exn ) { o . onError ( exn ) ; } ,
5230
+ function ( ) {
5231
+ inner . setDisposable ( notifier . subscribe ( recurse , function ( ex ) {
5232
+ o . onError ( ex ) ;
5233
+ } , function ( ) {
5234
+ o . onCompleted ( ) ;
5235
+ } ) ) ;
5236
+
5237
+ completions . onNext ( null ) ;
5238
+ outer . dispose ( ) ;
5239
+ } ) ) ;
5240
+ } ) ;
5241
+
5242
+ return new NAryDisposable ( [ notificationDisposable , subscription , cancelable , createDisposable ( state ) ] ) ;
5243
+ } ;
5244
+
5245
+ return RepeatWhenObservable ;
5246
+ } ( ObservableBase ) ) ;
5247
+
5248
+ observableProto . repeatWhen = function ( notifier ) {
5249
+ return new RepeatWhenObservable ( repeat ( this ) , notifier ) ;
5250
+ } ;
5251
+
5140
5252
var ScanObservable = ( function ( __super__ ) {
5141
5253
inherits ( ScanObservable , __super__ ) ;
5142
5254
function ScanObservable ( source , accumulator , hasSeed , seed ) {
@@ -9869,7 +9981,7 @@ Observable.fromNodeCallback = function (fn, ctx, selector) {
9869
9981
}
9870
9982
9871
9983
return new BinaryDisposable ( subscription , delays ) ;
9872
- } , this ) ;
9984
+ } , source ) ;
9873
9985
}
9874
9986
9875
9987
/**
0 commit comments