我的应用有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);
});
})
如果同时点击多个按钮,将分派2个DownloadFileAction操作
Howerver,download_attachment $ effect只侦听首先下载的一个然后返回DownloadAttachmentSuccessAction,因此其他下载文件将无法完成
有任何解决方案或解决方法吗? 非常感谢您的想法