One more rule: no “new Promise” in your code. There’s virtually never any need for it in app code, and it interferes with allowing types to shine through properly (and silently eats errors the way you’re using it, which is bad).
I discussed before how it’s important to avoid the crutch of any
, especially when you’re starting out, because it inhibits your toolchain’s ability to help you diagnose problems. So declare an interface
for all business-level objects. My minimal French is going to say searchOrg
wants to return a list of Friend
s:
export interface Friend {
name: string;
...
}
searchOrg(uid: string): Observable<Friend[]> {
return this.afDB.list(`Attente/${this.userID}/Amis`)
.snapshotChanges(["child_added", "child_removed"]).pipe(
map(actions => actions.map(action => action.key)));
}
this.searchOrg().subscribe(friends => this.invite(friends));