I use Firestore like so.
Use case 1:
contacts$: Observable<ContactDetail[]>;
constructor(){
}
ionViewDidEnter() {
this.contacts$ = this.contactProvider.getSpecificUserContacts(this.authenticationProvider.user.uid).valueChanges();
this.contacts$.pipe(first()).subscribe(res => { },
err => { },
() => { }
);
}
Use case 2:
getAllContactCategories() {
this.categories$ = this.categoryProvider.getAllContactCategories().valueChanges();
this.categories$.subscribe(res => {
this.categorySortedList = res;
},
err => { }
);
}
But I have never unsubscribed
it. So do I need to do that? Otherwise, will it lead to memory leaks and draining the battery usage?
I know we don't need to unsubscribed
angular HTTP
services since it does automatically by the framework itself. So what about Firestore/Angularfire2 observables
? I have never seen such a pattern with firestore books or articles or like so.