Please, take a look at the following try for better understanding:
this.loading = true;
obs.pipe(
finalize(() => this.loading = false) //If set to false he
You should use the switchMap operator to combine the two observables into one:
this.loading = true;
loadParent().pipe(
switchMap(parent => {
if (person.children) {
return loadChildrenOf(parent).pipe(
map(children => ({ parent, children })
)
} else {
return of({parent, children: [] })
}
}),
finalize(() => this.loading = false)
).subscribe(({ parent, children }) => {
// Do stuff with the parent and its children
});