December 2018
Intermediate to advanced
196 pages
4h 48m
English
I’ve prepared a slightly different observable for you in errors.js. This new observable still has all the requests, but they hit a different endpoint on the node server. This new endpoint is programmed to give up and start spitting errors after several dozen requests. Using your knowledge from earlier in the chapter, pass in a function to handle the case where some requests fail to complete.
| | loadingRequestsBad$ |
| | .pipe( |
| | scan((prev) => prev + (100 / arrayOfRequests.length), 0) |
| | ) |
| | .subscribe(percentDone => { |
| | progressBar.style.width = percentDone + '%'; |
| | progressBar.innerText = Math.round(percentDone) + '%'; |
| | }, err => { |
| | console.log(err); |
| | msgArea.innerText = 'Something ... |
Read now
Unlock full access