I have next function:
saveTable() {
...
let promises = [];
for (index = 0; index < this._TOTAL.length; ++index) {
let promise = this.db.object(ref).update(this._TOTAL[index]);
promises.push(promise);
}
Observable.forkJoin(promises).subscribe(() => {
this.messagesService.createMessage('success', `Saved`);
this.router.navigate(['/dashboard/my-calculations']);
})
}
How can i handle error in this case? Actually, i just need to use then
and catch
after all my promises resolve, so using forkJoin
for me not fundamentally.
you can do code as below
bascially make use of
catchError
operator , it will do for youCheck for detail here : Way to handle Parallel Multiple Requests
forkJoin
will throw an error if any (at least one) of theObservables
it is fork-joining throws an error. You can handle it at your error handler: