mesqueeb / vuex-easy-firestore

Easy coupling of firestore and a vuex module. 2-way sync with 0 boilerplate!
https://mesqueeb.github.io/vuex-easy-firestore
MIT License
233 stars 28 forks source link

Two-way binding #369

Closed tormjens closed 3 years ago

tormjens commented 3 years ago

I love the prospect of keeping a "persistent store" with the help of Firebase, but one questions came up while implementing this to my project:

Does two-way binding work? Let's say I populate a form with data from my Firebase integration, and then change the value in one of the fields in the form. Is this supposed to be saved to Firebase? If yes, is there anything I have to "turn on" for it to work. If no, then have other people encountered such a "need".

I have dispatched openDBChannel on my store, and changes are reflected if I update a value inside Firestore. However, it does not work like that the other way around.

Thanks for your excellent work on this. It is truly a awesome package.

mesqueeb commented 3 years ago

Hey tormjens : ) You need to use the write actions to modify data! This is what syncs the changes to the server. ;)

Let me know if you've got any other questions !

mesqueeb commented 3 years ago

I'll close the issue but feel free to continue the conversation

tormjens commented 3 years ago

Thanks for your response.

So I can’t just v-model a key in a document directly then?

louisameline commented 3 years ago

It is an anti-pattern, so no. But you can create a computed property with a setter that calls the action.