posva / vuexfire

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

why setting Refs includes both . bindFirebaseRef and unbindFirebaseRefs ? #179

Closed ghost closed 6 years ago

ghost commented 6 years ago

In the doc , you state that we should add the following action in the store/root.js

setDetailsRef: firebaseAction(({ bindFirebaseRef, unbindFirebaseRef }, ref) => { bindFirebaseRef('details', ref) unbindFirebaseRef('details') }),

to be called with

`this.$store.dispatch('setUserDetailsRef', db.ref('details')`

I do not understand why there is a binding followed by an unbind , can you explain it ?

should not it be=

setDetailsRef: firebaseAction(({ bindFirebaseRef, unbindFirebaseRef }, ref) => { if (ref === null) { unbindFirebaseRef('details') } else { bindFirebaseRef('details', ref) } }),

thanks

posva commented 6 years ago

Hello, it is just for the sake of the example. As the comment says: it is possible to unbind a bound key at any time I'll change it to another ref so it's less confusing 🙂