Here's a solution you can try:
this.productServices.onProductBuy(product_id).pipe(
retry({
delay: 30 * 1000
} as any)
).subscribe(response => {
console.log(response)
});
This will attempt to retry infinitely and introduce a 30-second delay between retries. It appears that the type definition for retry
is not functioning correctly in the version I am using, hence the need for as any
.
However, looking at the source code, it is evident that retry
actually accepts an object with a delay property:
export interface RetryConfig {
/**
* The maximum number of times to retry. If `count` is omitted, `retry` will try to
* resubscribe on errors infinite number of times.
*/
count?: number;
/**
* The number of milliseconds to delay before retrying, OR a function to
* return a notifier for delaying. If a function is given, that function should
* return a notifier that, when it emits will retry the source. If the notifier
* completes _without_ emitting, the resulting observable will complete without error,
* if the notifier errors, the error will be pushed to the result.
*/
delay?: number | ((error: any, retryCount: number) => ObservableInput<any>);
/**
* Whether or not to reset the retry counter when the retried subscription
* emits its first value.
*/
resetOnSuccess?: boolean;
}
export function retry<T>(count?: number): MonoTypeOperatorFunction<T>;
export function retry<T>(config: RetryConfig): MonoTypeOperatorFunction<T>;