Can't access rootNav after upgrade to Beta 11

What I do is to simply modify the rootPage property of the app component, and let Ionic do the rest. For example, I frequently have an authentication provider service, that is responsible for interacting with storage and authentication servers. It exposes an Observable<boolean> (that is internally a ReplaySubject with a stack depth of 1). In the app’s constructor, I do something like this:

_sink.authenticationNotifier().subscribe((authed) => {
  if (authed) {
    this.rootPage = TabsPage;
  } else {
    this.rootPage = LoginPage;
  }
});

This gives you logout functionality for virtually free. Anybody can inject the provider of the authentication notifier, call logout on it, which internally calls authenticationNotifier.next(false) and you don’t have to worry about futzing with navigation.

3 Likes