where to place firebase.auth().onAuthStateChanged() in Vuejs

In the created () method of the main.js file


In cases I am not using Vuex, I am using the FBase this way:

<script>
import * as firebase from 'firebase'

return default {
  el: '#app',
  data: {
    user: '',
    fb: null,
    fbConf: {
      apiKey: 'your API key',
      authDomain: '<your-domain>.firebaseapp.com'
    }
  },
  methods: {
    logIn (user) {
      this.user = user.uid
    },
  },
  created () {
    this.fb = firebase
    this.fb.initializeApp(this.fbConf)
    this.fb.auth().signInAnonymously()
    this.fb.auth().onAuthStateChanged(this.logIn)
  }
}
</script>