When trying to call nav.setRoot(Page) from a subscribe method of a Observable/Stream the view does not update until a interaction with a controller inside the page occurs.
I have only tried with Observables, but I guess many asynchronous operations will have the same behavior.
A page navigation to occur and the RootPage reference to be updated.
Steps to reproduce:
The code below works, but if I remove the zone.run() method, it does not.
let auth$ = this.store.select('auth');
auth$
.filter(auth => auth.isAuthenticated)
.take(1)
.subscribe(
() => {
this.zone.run(
() => { this.goToMainPage(); }
)
}
);
Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)
I found a workaround solution on this Stack Overflow question
And there is a discussion about it here in the ionic forum(at the bottom, since there is a lot of replies): https://forum.ionicframework.com/t/ionic2-with-real-time-data-not-updating-firebase/47189/42
This may relate to:
Which Ionic Version? 1.x or 2.x
2.x
(beta.6)
Run ionic info from terminal/cmd prompt: (paste output below)
Cordova CLI: 5.4.1
Gulp version: CLI version 3.9.0
Gulp local: Local version 3.9.1
Ionic Framework Version: 2.0.0-beta.6
Ionic CLI Version: 2.0.0-beta.25
Ionic App Lib Version: 2.0.0-beta.15
ios-deploy version: 1.8.4
ios-sim version: 5.0.6
OS: Mac OS X El Capitan
Node Version: v4.0.0
Xcode version: Xcode 7.3 Build version 7D175
After searching @iignatov comments on many topics on the Ionic forum, I believe the issue is probably related to zone.js itself and is reported already here: https://github.com/angular/zone.js/issues/304
Hey! Thanks for opening an issue with us! The next release of Ionic 2 should be upgraded to Angular 2 rc1 which includes the fix that happened with zone.js in Angular 2 beta.17.
Most helpful comment
Hey! Thanks for opening an issue with us! The next release of Ionic 2 should be upgraded to Angular 2 rc1 which includes the fix that happened with zone.js in Angular 2 beta.17.