Commit 573c5f34 authored by Ryan Diehl's avatar Ryan Diehl

feat(rx): adds expireRequest operator

parent 05aaa99e
Pipeline #113093 passed with stages
in 4 minutes and 49 seconds
export { httpRetryBackoff, HttpRetryBackoffConfig } from './lib/http-backoff';
export { expireRequest } from './lib/expire-request';
import { Observable, race, throwError, timer } from 'rxjs';
import { switchMapTo } from 'rxjs/operators';
export const expireRequest = (timeout: number) => <T>(source: Observable<T>): Observable<T> =>
race(
source,
timer(timeout).pipe(
switchMapTo(
throwError({ message: 'Error: request timeout expired', status: 504 })
)
)
);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment