posva / vuexfire

Check
https://github.com/vuejs/vuefire
MIT License
558 stars 49 forks source link

SSR bindFirebaseRef #188

Closed baronTommy closed 5 years ago

baronTommy commented 6 years ago

Nuxt.js + vuexfire Does it work with SSR?

pages/users.vue

// bind NG
async fetch({store}) {
   await store.dispatch('users/bindFirebase')
},

// bind NG
async asyncData({store}) {

   await store.dispatch('users/bindFirebase')
},

// bind OK
async created () {
    await this.$store.dispatch('users/bindFirebase')
}

store/users.js

bindFirebase: firebaseAction(async ({bindFirebaseRef}) => {
    await bindFirebaseRef('list', usersRef)
})
posva commented 5 years ago

yes, it works if you wait for bindFirebaseRef in asyncData

baronTommy commented 5 years ago

@posva Thank you

dac3971 commented 5 years ago

@posva is there a simple example of bindFirebaseRef with Nuxt for Firestore? I'm simply trying to bind to a single document. I have my dispatch in asyncData as below,. It fetches the data initially but doesn't update live.

async asyncData ({params,store}){ if(store.getters.user.uid) await store.dispatch('g/checkFollowing',groups/${params.id}/follows/${store.getters.user.uid}) return {} },