I do not know if there is an easier way, but I would use concatMap()and recursively call deleteDocument()using the identifier returned from the previous call:
This should mimic your situation:
import {Observable} from 'rxjs';
function deleteDocument(willFail: bool, id) {
return Observable.of("I'm your response: " + id)
.concatMap(val => {
if (willFail) {
return Observable.throw({response: val, message: "It broken"});
} else {
return Observable.of(val);
}
})
.catch(initialError => {
return deleteDocument(false, initialError.response.length);
});
}
deleteDocument(true, 42).subscribe(result => console.log(result));
See the demo: http://plnkr.co/edit/rUbLgEwtw7lSBueKJ5HN?p=preview
:
I'm your response: 21
willFail. concatMap , . id .
intercept() , HTTP-, this.getTicket().do() :
return this.getTicket().concatMap(response => {
var newBody = {id: response.ticketId};
return this.post(originalUrl, newBody, ...);
});
do() , , .
, , , .
, : Observable API