Trying to use vuexfire for Firebase bindings, the documentation state to insert the following action for binding
const setTodosRef = firebaseAction(({ bindFirebaseRef, unbindFirebaseRef }, { ref }) => {
// bunding will automatically unbind any previously bound ref so you
// don't need to unbind before binding over an existing bound key
bindFirebaseRef('todos', ref)
// it is possible to unbind a bound key at any time
unbindFirebaseRef('todos')
})
In my store root.js , all the actions are written with the following pattern
/**
* Import Dependency
*/
import * as types from './mutation_types'
import i18n from '@/locales'
import * as firebase from 'firebase'
import { firebaseMutations, firebaseAction } from 'vuexfire'
setTodosRef ( ) {
bindFirebaseRef('todos', ref)
unbindFirebaseRef('todos')
}
How can I pass the parameters to the function ? in order to call
this.$store.dispatch('setTodosRef', db.ref('todos'))
setTodosRef (firebaseAction(({ bindFirebaseRef, unbindFirebaseRef }, { ref })) { ... }
doesn't work...
Syntax Error: Unexpected token, expected "," (119:29)
thanks for feedback
UPDATE
I removed the syntax error using
setTodosRef: firebaseAction(({ bindFirebaseRef, unbindFirebaseRef }, ref) => {
bindFirebaseRef('todos', ref)
unbindFirebaseRef('todos')
})
but I am not sure that's correct... ?
Your store actions are going to take two arguments. The first is a context object passed by vuex and is typically dereferenced. I don't have all of your code, so I can't write an exact method for you, but it needs to be something like this (assuming es6):
Then you would have a mutation that handles the commit. It also receives an injected parameter as the first argument from vuex, then you provide the data in the second argument like:
https://vuex.vuejs.org/guide/actions.html