April 27, 2016
  • All
  • Ionic
  • Ionic 2

Screencast: Ionic & Async

Mike Hartington

Director of Developer Relation...

Ionic 2 offers a powerful NavController that allows you to show new pages, alerts, modals, and even loading indicators. But what happens when you need to coordinate multiple events around a single API call? All of these event are asynchronous and could return at any given time, so how can we put it all together?

In this screencast, we’ll look at a situation just like this and figure out what our best practices should be.

The sample code used in this screencast can be found here.

  callLoad() {
    let alert = Alert.create({
      title: 'Async',
      message: '',
      buttons: [{
        text: 'Ok',
        handler: () => {
          this.data.load().then(()=>{
            alert.dismiss().then(()=>{
              this.nav.pop();
            })
          })
          return false;
        }
      }]
    });
    this.nav.present(alert);
  }

Mike Hartington

Director of Developer Relation...