I have a ionic2 app with ngrx/store implemented and i'm encountering a strange behaviour.
nav:Subscription;
ngOnInit(): void {
this.nav = this.store.select(fromRoot.getLoginState).subscribe(res => {
if(res){
this.navCtrl.setRoot(TabsPage);
}
})
}
ngOnDestroy(): void {
this.nav.unsubscribe()
}
store.select(fromRoot.getLoginState) returns a boolean and if it's true I want to set TabsPage as root in Ionic 2. Obviously I only want it to happen once so I unsubscribe in the onDestroy lifecycle hook.
However the unsubscription doesn't seem to work and each time i get a state change it set the view back to Tabspage (so the subscription still fires)
Any ideas?
Cheers