Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about the example #1

Open
Frondor opened this issue May 8, 2017 · 1 comment
Open

Question about the example #1

Frondor opened this issue May 8, 2017 · 1 comment

Comments

@Frondor
Copy link

Frondor commented May 8, 2017

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?

@mornir
Copy link

mornir commented Sep 18, 2017

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)
          }
        })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants