我的应用有 3 个下载按钮 每个按钮单击都会调度DownloadFileAction(payload=fileId) 一个 Effect 将继续监听 Download_File_Action 类型
@effect()
download_attachment$: Observable = this.actions$
.ofType(FileActions.ActionTypes.DOWNLOAD_ATTACHMENT)
.map(toPayload)
.switchMap( attachment => {
return this.service.downloadAttachment(attachment.link) //absolute link
.map( (data) => {
this.service.saveAttachment(data); //save file locally
return new FileActions.DownloadAttachmentSuccessAction(attachment);
})
.catch(error => {
//debugger;
console.log(error);
});
})
如果同时点击了 1 个以上的按钮,则会分派 2 个 DownloadFileAction 动作
但是,download_attachment$ effect 只监听一个先下载的,然后返回 DownloadAttachmentSuccessAction,所以其他的下载文件不会完成
有什么解决方案或解决方法吗?非常感谢您的想法