Angular-RxJS-在长API调用中间隐藏微调器并继续API调用



API调用的响应时间在2到30秒之间变化。在初始化API调用之后,如果API调用将花费超过5秒,在第6秒的时候,我必须表演一些操作(隐藏微调器(,并且调用必须继续,直到完成

RxJS运算符的最佳组合是什么?

使用Rx延迟应该能够在特定时间延迟后触发操作

import { of } from 'rxjs';
import { delay } from 'rxjs/operators';
doSomething(): Observable<boolean> {
//place your logic here 
return of(true);
} //you can specify what type of observable to use number, string etc..
const $delayed 
= doSomething
.pipe(delay(6000))
.subscribe(e => console.log(e));

最新更新