suppose i have two methods which returns an observable
method1(): Observable<any> {
returns data or null;
}
method2(): Observable<any> {
always returns data;
}
Now i call method1 first, if this returns some data, then don't call method2, otherwise call method2.
I can do something like this,
this.method1().subscribe(data => {
if(data == null)
this.method2().subscribe(data => {
return data;
})
else {
return data;
}
})
But i think, this is not the proper way to handle this situation. It can be handled very easily with Observable Operators which i am missing.