Created
March 20, 2018 14:20
-
-
Save Solomko2/636d0518794f9f581b52e23b2e273eb7 to your computer and use it in GitHub Desktop.
angular ngrx forkJoin upload multiple
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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