I have a conceptual question. I am using angularfire2 with angular 6, and I am not sure how to handle all the observables.
Most of my pages need user, which is an observable, then they might need a query parameter, which is another observable. So I have some code doing like
zip(
this.route.paramMap,
this._auth.user
)
.pipe(
switchMap((val: [ParamMap, User]) => {
this.url = `/users/${val['1'].uid}/dto/${val['0'].get('id')}`;
return this._fireStore.doc(this.url).snapshotChanges();
}),
switchMap((val: Action<DocumentSnapshot<any>>) => {
let data = val.payload.data();
return of(Dto.fromPayLoad(val.payload.id, data));
})).subscribe(it => this.model = it);
I feel like it is overly complicated. What is the stablished patterns here? Can someone point me to best practises.