1
1
import { Observable } from '../Observable' ;
2
+ import { innerFrom } from '../observable/innerFrom' ;
2
3
import { Subject } from '../Subject' ;
3
4
import { Subscription } from '../Subscription' ;
4
5
5
- import { MonoTypeOperatorFunction } from '../types' ;
6
+ import { MonoTypeOperatorFunction , ObservableInput } from '../types' ;
6
7
import { operate } from '../util/lift' ;
7
8
import { createOperatorSubscriber } from './OperatorSubscriber' ;
8
9
9
10
/**
10
11
* Returns an Observable that mirrors the source Observable with the exception of an `error`. If the source Observable
11
- * calls `error`, this method will emit the Throwable that caused the error to the Observable returned from `notifier`.
12
+ * calls `error`, this method will emit the Throwable that caused the error to the `ObservableInput` returned from `notifier`.
12
13
* If that Observable calls `complete` or `error` then this method will call `complete` or `error` on the child
13
14
* subscription. Otherwise this method will resubscribe to the source Observable.
14
15
*
@@ -55,13 +56,15 @@ import { createOperatorSubscriber } from './OperatorSubscriber';
55
56
*
56
57
* @see {@link retry }
57
58
*
58
- * @param { function(errors: Observable): Observable } notifier - Receives an Observable of notifications with which a
59
+ * @param notifier Function that receives an Observable of notifications with which a
59
60
* user can `complete` or `error`, aborting the retry.
60
- * @return A function that returns an Observable that mirrors the source
61
+ * @return A function that returns an `ObservableInput` that mirrors the source
61
62
* Observable with the exception of an `error`.
62
63
* @deprecated Will be removed in v9 or v10, use {@link retry}'s `delay` option instead.
64
+ * Will be removed in v9 or v10. Use {@link retry}'s {@link RetryConfig#delay delay} option instead.
65
+ * Instead of `retryWhen(() => notify$)`, use: `retry({ delay: () => notify$ })`.
63
66
*/
64
- export function retryWhen < T > ( notifier : ( errors : Observable < any > ) => Observable < any > ) : MonoTypeOperatorFunction < T > {
67
+ export function retryWhen < T > ( notifier : ( errors : Observable < any > ) => ObservableInput < any > ) : MonoTypeOperatorFunction < T > {
65
68
return operate ( ( source , subscriber ) => {
66
69
let innerSub : Subscription | null ;
67
70
let syncResub = false ;
@@ -72,7 +75,7 @@ export function retryWhen<T>(notifier: (errors: Observable<any>) => Observable<a
72
75
createOperatorSubscriber ( subscriber , undefined , undefined , ( err ) => {
73
76
if ( ! errors$ ) {
74
77
errors$ = new Subject ( ) ;
75
- notifier ( errors$ ) . subscribe (
78
+ innerFrom ( notifier ( errors$ ) ) . subscribe (
76
79
createOperatorSubscriber ( subscriber , ( ) =>
77
80
// If we have an innerSub, this was an asynchronous call, kick off the retry.
78
81
// Otherwise, if we don't have an innerSub yet, that's because the inner subscription
0 commit comments