【发布时间】:2021-01-22 11:40:29
【问题描述】:
实际上,我们正在尝试避免在文件上传过程中阻止用户进行其他操作。
如果在 5 秒内使用 rxjs 在 angular 中未完成 api,我如何显示 toastr 并隐藏加载器。
uploadFile() {
this.service.uploadFile(data)
.pipe(
//i am looking for operator which will wait 5 sec if and then hide the loader and show the toastr
)
.subscribe(() => {
this.toastr.success('file uploaded successfully');
this.loader.hide();
})
}
提前致谢
【问题讨论】:
-
问题目前并不完全清楚。如果未在 5 秒内完成,您是否希望取消正在进行的请求?或者您是否只想隐藏加载程序并在请求超过 5 秒时显示一条消息作为副作用?
-
谢谢,我只需要隐藏和显示消息@MichaelD
标签: javascript angular rxjs