angular ngrx forkJoin upload multiple
@Effect()
multiple$ = this.actions.pipe(
ofType(fromActions.UPLOAD_BILL),
withLatestFrom(this.store.select(fromStrpGeneralSelectors.selectBuildingId)),
map(([action, buildingId]): any => {
return {action, buildingId};
}),
mergeMap(({action, buildingId}) => {
const {files, category} = action.payload;
const dists = files.map((file) => {
return this.buildingSettingsService.saveBill(buildingId, {document: file, category: category});
});
return forkJoin(dists).pipe(
map((res: any) => {
console.log('download completed');
return new fromActions.UploadBillSuccess(res)
}),
catchError(res => of(new fromActions.UploadBillFailure(res.error)))
);
})
);