Skip to content

Instantly share code, notes, and snippets.

@binzailani3136
Created August 23, 2016 17:07
Show Gist options
  • Save binzailani3136/799edc5a6911abf2b1351c2535d733a0 to your computer and use it in GitHub Desktop.
Save binzailani3136/799edc5a6911abf2b1351c2535d733a0 to your computer and use it in GitHub Desktop.
import * as firebase from 'firebase';
const firebaseConfig = {
apiKey: "AIzaSyAfHOFdjPwByt_S7RSPcyF5OPzwp_????",
authDomain: "??????-44ce2.firebaseapp.com",
databaseURL: "https://??????-44ce2.firebaseio.com",
storageBucket: "",
};
const app = firebase.initializeApp(firebaseConfig);
var user = firebase.auth().currentUser;
if (user != null) {
this.itemsRef = this.getRef().child('Stores/'+user.uid+'/');
}else {
alert('you have to login again!');
};
const connectedRef = firebase.database().ref('.info/connected');
connectedRef.on('value', snap => {
if (snap.val() === true) {
this.listenForItems(this.itemsRef);
} else {
this.offlineForItems();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment