Created
May 26, 2017 12:16
-
-
Save CookieCookson/9b8d1e559cff666a68166c2992b542c0 to your computer and use it in GitHub Desktop.
Check firebase logged in state
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ion-content> | |
<ion-spinner ion-fixed></ion-spinner> | |
</ion-content> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
page-loader { | |
.fixed-content { | |
display: flex; | |
align-items: center; | |
justify-content: center; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
import { NavController, NavParams } from 'ionic-angular'; | |
import { AngularFireAuth, FirebaseAuthState } from 'angularfire2'; | |
import { WelcomePage } from '../welcome/welcome'; | |
import { SplitPage } from '../split/split'; | |
@Component({ | |
selector: 'page-loader', | |
templateUrl: 'loader.html' | |
}) | |
export class LoaderPage { | |
constructor( | |
public navCtrl: NavController, | |
public navParams: NavParams, | |
public auth$: AngularFireAuth | |
) { | |
let authSubscription = auth$.subscribe((state: FirebaseAuthState) => { | |
// Stop checking for auth status change | |
authSubscription.unsubscribe(); | |
// state.uid | |
if (state === null) { | |
navCtrl.setRoot(WelcomePage); | |
} else { | |
this.navCtrl.setRoot(SplitPage); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment