Skip to content

Instantly share code, notes, and snippets.

@Solomko2
Created March 20, 2018 14:20
Show Gist options
  • Save Solomko2/636d0518794f9f581b52e23b2e273eb7 to your computer and use it in GitHub Desktop.
Save Solomko2/636d0518794f9f581b52e23b2e273eb7 to your computer and use it in GitHub Desktop.
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)))
);
})
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment