nuxt-community / firebase-module

🔥 Easily integrate Firebase into your Nuxt project. 🔥
https://firebase.nuxtjs.org
MIT License
642 stars 98 forks source link

Auth callbacks can only be used in store/index.js? Not with namespaced modules? #328

Closed AdamBD closed 4 years ago

AdamBD commented 4 years ago

I am following the docs for the auth module:

This sets up an onAuthStateChanged() listener and hooks it up to the vuex store.

Just add a mutation/action to your vuex store

From my testing this only works if you have a store/index.js file structure.

However from the Nuxt.js vueX documentation they write the following:

Classic (deprecated): store/index.js returns a method to create a store instance.

I assume that the preference is that all vueX files will be namespaced.

Is there a way to get nuxt/firebase to work from a namespaced module?

lupas commented 4 years ago

@AdamBD

It should also work with namespaces. Did you try setting the action/mutation like so?

 initialize: {
    onAuthStateChangedAction: 'namespace123/action123'
  }
AdamBD commented 4 years ago

ah no didn't know that you could use namespaces in the value, thanks! (Good to add to the documentation if possible.)

lupas commented 4 years ago

ah no didn't know that you could use namespaces in the value, thanks! (Good to add to the documentation if possible.)

Thanks for the input, just added it with https://github.com/nuxt-community/firebase-module/commit/e0305cf6e7bb7fb92c4d37e50cde9fd190eb0e3b . 👍