Skip to content

Instantly share code, notes, and snippets.

@CookieCookson
Created May 26, 2017 12:16
Show Gist options
  • Save CookieCookson/9b8d1e559cff666a68166c2992b542c0 to your computer and use it in GitHub Desktop.
Save CookieCookson/9b8d1e559cff666a68166c2992b542c0 to your computer and use it in GitHub Desktop.
Check firebase logged in state
<ion-content>
<ion-spinner ion-fixed></ion-spinner>
</ion-content>
page-loader {
.fixed-content {
display: flex;
align-items: center;
justify-content: center;
}
}
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