I have a use case where I need to make two async calls. order is important here. The first call needs to complete (or fail) before starting the next call.
I have a example code below showing what I need but it is not done in a reactive way (ie. using rxjs operators)
public performDBTasks(): Observable<void> {
return Observable.create(
(observer)=> {
this.performDBTask1().subscribe(
()=> {
this.performDBTask2().subscribe(
()=> {
observer.next();
observer.complete();
},
()=> {
observer.error();
});
},
(error)=> {
this.performDBTask2().subscribe(
()=> {
observer.next();
observer.complete();
},
()=> {
observer.error();
});
});
});
}
Update: just to clarify the two calls are http like calls so they will return data & complete or error. There will be no stream of data.