Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 230760

Problems async method

$
0
0

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 Friends:

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));

Viewing all articles
Browse latest Browse all 230760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>