Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate retryWhen and repeatWhen #6859

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions spec-dtslint/operators/repeatWhen-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { of } from 'rxjs';
import { repeatWhen } from 'rxjs/operators';

it('should infer correctly', () => {
const o = of(1, 2, 3).pipe(repeatWhen(errors => errors)); // $ExpectType Observable<number>
});

it('should infer correctly when the error observable has a different type', () => {
const o = of(1, 2, 3).pipe(repeatWhen(repeatWhen(errors => of('a', 'b', 'c')))); // $ExpectType Observable<number>
});

it('should enforce types', () => {
const o = of(1, 2, 3).pipe(repeatWhen()); // $ExpectError
});

it('should enforce types of the notifier', () => {
const o = of(1, 2, 3).pipe(repeatWhen(() => 8)); // $ExpectError
});

it('should be deprecated', () => {
const o = of(1, 2, 3).pipe(repeatWhen(() => of(true))); // $ExpectDeprecation
});
4 changes: 4 additions & 0 deletions spec-dtslint/operators/retryWhen-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ it('should enforce types', () => {
it('should enforce types of the notifier', () => {
const o = of(1, 2, 3).pipe(retryWhen(() => 8)); // $ExpectError
});

it('should be deprecated', () => {
const o = of(1, 2, 3).pipe(retryWhen(() => of(true))); // $ExpectDeprecation
});
1 change: 1 addition & 0 deletions src/internal/operators/repeatWhen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { createOperatorSubscriber } from './OperatorSubscriber';
* which a user can `complete` or `error`, aborting the repetition.
* @return A function that returns an Observable that that mirrors the source
* Observable with the exception of a `complete`.
* @deprecated Will be removed in v9 or v10. Use {@link repeat}'s `delay` option instead.
*/
export function repeatWhen<T>(notifier: (notifications: Observable<void>) => Observable<any>): MonoTypeOperatorFunction<T> {
return operate((source, subscriber) => {
Expand Down
1 change: 1 addition & 0 deletions src/internal/operators/retryWhen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import { createOperatorSubscriber } from './OperatorSubscriber';
* user can `complete` or `error`, aborting the retry.
* @return A function that returns an Observable that mirrors the source
* Observable with the exception of an `error`.
* @deprecated: Will be removed in v9 or v10, use {@link retry}'s `delay` option instead.
*/
export function retryWhen<T>(notifier: (errors: Observable<any>) => Observable<any>): MonoTypeOperatorFunction<T> {
return operate((source, subscriber) => {
Expand Down