| /******************************************************************************** |
| * Copyright (c) 2020 Contributors to the Eclipse Foundation |
| * |
| * See the NOTICE file(s) distributed with this work for additional |
| * information regarding copyright ownership. |
| * |
| * This program and the accompanying materials are made available under the |
| * terms of the Eclipse Public License 2.0 which is available at |
| * http://www.eclipse.org/legal/epl-2.0 |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| ********************************************************************************/ |
| import {pipe} from "rxjs"; |
| import {delay, retryWhen} from "rxjs/operators"; |
| |
| /** |
| * If an error occurs, the observable is repeated after a given amount of time. |
| * @param timeInMs Time in miliseconds after which the observable is repeated. |
| */ |
| export function retryAfter<T>(timeInMs: number) { |
| return pipe( |
| retryWhen<T>((errors) => errors.pipe(delay(timeInMs))) |
| ); |
| } |