Can async/await be used for component lifecycle functions?


#1

Is it OKay to add async/await to component’s lifecycle hooks? Like:

  async ngOnInit() {
    this.thread = await this.threadService.getThread(this.user.uid);
  }

  async ionViewWillLeave() {
    await this.threadService.delete(this.user.uid);
  }

  async ionViewDidEnter() {
    await this.threadService.update(this.user.uid);
  }

How about the event handler of the HTML? Can I mark them async/await? like:

<button ion-button (click)="send()">
async send() {
    await this.threadService.send(this.user.uid);
}

Will it work? Or I should expect weird behaviours?