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

docs(retry): fix rendering docs #6850

Merged
merged 2 commits into from Mar 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 22 additions & 21 deletions src/internal/operators/retry.ts
Expand Up @@ -6,9 +6,14 @@ import { identity } from '../util/identity';
import { timer } from '../observable/timer';
import { innerFrom } from '../observable/innerFrom';

/**
* The {@link retry} operator configuration object. `retry` either accepts a `number`
* or an object described by this interface.
*/
export interface RetryConfig {
/**
* The maximum number of times to retry.
* The maximum number of times to retry. If `count` is omitted, `retry` will try to
* resubscribe on errors infinite number of times.
*/
count?: number;
/**
Expand All @@ -26,17 +31,25 @@ export interface RetryConfig {
resetOnSuccess?: boolean;
}

export function retry<T>(count?: number): MonoTypeOperatorFunction<T>;
export function retry<T>(config: RetryConfig): MonoTypeOperatorFunction<T>;

/**
* Returns an Observable that mirrors the source Observable with the exception of an `error`. If the source Observable
* calls `error`, this method will resubscribe to the source Observable for a maximum of `count` resubscriptions (given
* as a number parameter) rather than propagating the `error` call.
* Returns an Observable that mirrors the source Observable with the exception of an `error`.
*
* If the source Observable calls `error`, this method will resubscribe to the source Observable for a maximum of
* `count` resubscriptions rather than propagating the `error` call.
*
* ![](retry.png)
*
* Any and all items emitted by the source Observable will be emitted by the resulting Observable, even those emitted
* during failed subscriptions. For example, if an Observable fails at first but emits `[1, 2]` then succeeds the second
* time and emits: `[1, 2, 3, 4, 5]` then the complete stream of emissions and notifications
* would be: `[1, 2, 1, 2, 3, 4, 5, complete]`.
* The number of retries is determined by the `count` parameter. It can be set either by passing a number to
* `retry` function or by setting `count` property when `retry` is configured using {@link RetryConfig}. If
* `count` is omitted, `retry` will try to resubscribe on errors infinite number of times.
*
* Any and all items emitted by the source Observable will be emitted by the resulting Observable, even those
* emitted during failed subscriptions. For example, if an Observable fails at first but emits `[1, 2]` then
* succeeds the second time and emits: `[1, 2, 3, 4, 5, complete]` then the complete stream of emissions and
* notifications would be: `[1, 2, 1, 2, 3, 4, 5, complete]`.
*
* ## Example
*
Expand All @@ -63,22 +76,10 @@ export interface RetryConfig {
*
* @see {@link retryWhen}
*
* @param count - Number of retry attempts before failing.
* @param resetOnSuccess - When set to `true` every successful emission will reset the error count
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This parameter doesn't exist anymore in this form, so I removed the docs for it. It is now part of the RetryConfig and it's properly documented.

* @param configOrCount - Either number of retry attempts before failing or a {@link RetryConfig} object.
* @return A function that returns an Observable that will resubscribe to the
* source stream when the source stream errors, at most `count` times.
*/
export function retry<T>(count?: number): MonoTypeOperatorFunction<T>;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved here.


/**
* Returns an observable that mirrors the source observable unless it errors. If it errors, the source observable
* will be resubscribed to (or "retried") based on the configuration passed here. See documentation
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved here.

* for {@link RetryConfig} for more details.
*
* @param config - The retry configuration
*/
export function retry<T>(config: RetryConfig): MonoTypeOperatorFunction<T>;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved here.


export function retry<T>(configOrCount: number | RetryConfig = Infinity): MonoTypeOperatorFunction<T> {
let config: RetryConfig;
if (configOrCount && typeof configOrCount === 'object') {
Expand Down