How can the outer Observable be notified of success or error in nested Observables?
Why are onNext
and onCompleted
undefined within the inner Observable
?
public updateDocument(item: Document): Observable<any> {
this.firstUseOfflineContainer();
let afiEdit = this.offlineData.afi.edit;
//outer observable
return Observable.create(observer => {
//inner observable
this.dataService.updateRequest(item).subscribe(
(next) => {
console.log("ok");
},
(err) => {
afiEdit.headers.push(item);
//how to throw error to outer observable
},
() => {
observer.onNext(item);
observer.onCompleted();
}
);
return () => console.log('cleanup message')
});
}