vuefire-auth-demo
vuefire-auth-demo copied to clipboard
Question about the example
What does .bind(this) means on this line https://github.com/chrisbraddock/vuefire-auth-demo/blob/master/index.html#L50 ? What are why binding and where?
Also, I'm trying to get auth states working on a test app, and I'm checking whether user is logged in or not by calling this.$router.app.user on a child component (App.vue from Vue CLI) since I'm using vue-router, is it ok for you?
Hi Frondor! Just stick to using ES6 features (arrow functions, let/const, object-shorthands) and you will encounter less problems with scopes.
firebase.auth().onAuthStateChanged(user => {
if (user) {
this.user = user
this.$bindAsArray('messages', db.ref('messages/' + user.uid))
} else {
firebase.auth().signInAnonymously().catch(console.error)
}
})