New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarified role of the two binding methods #536
Conversation
to make it easier for beginners
Codecov Report
@@ Coverage Diff @@
## master #536 +/- ##
=======================================
Coverage 99.73% 99.73%
=======================================
Files 14 14
Lines 373 373
Branches 71 71
=======================================
Hits 372 372
Misses 1 1 Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this!
@@ -4,14 +4,14 @@ In Vuefire, subscriptions to changes are handled transparently, that's why we al | |||
|
|||
There are two ways of binding a Reference to the Database with Vuefire: | |||
|
|||
- Using the `firebase`/`firestore` option | |||
- Calling the injected methods `$bind`/`$rtdbBind` | |||
- Simple "declarative" method, which you can only use when you are always binding to the same source, for example, a data structure accessible to all users. This uses the `firebase` or `firestore` option inside `export default`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to keep it short here and add some details below in each section. I also think it would be better to match the titles, so keeping Declarative binding would be nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good thinking
|
||
Once a Reference is bound, Vuefire will keep the local version in sync with the remote database. However, this synchronisation **is only one-way**, the local state is always a reflection of the remote Database that you should treat as read only state. If you want to [push changes to the remote Database](./writing-data.md), you need to use Firebase JS SDK. But, more about that later. | ||
Once a Reference is bound, Vuefire will keep the local version updated in line with the remote database. However, this synchronisation **is only one-way**. Do not modify the variable, because (a) it will not change the remote Database and (b) it can be overwritten at any time by Vuefire. To [write changes to the Database](./writing-data.md), you must use the Firebase JS SDK. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated in line -> synchronized
modify the local variable
add (eg: this.user.name = 'John'
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great.
(I personally like to use "synchronize" for bidirectional stuff, and use "updated" for unidirectional, but it's only a personal preference and, after all, it is your excellent repo for which I am very grateful!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, I'm glad it's useful to you! In this case I prefer the word synchronize as it means something happening at the same time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am pretty new to Github and I (don't think) I have had comments on my pull requests so I don't know if I am doing this right. I have opened my patch on the web, made the edits requested (and a few other stylistic things) and am going to press "Submit review" and see what happens. Please let me know if i have done something wrong
8-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
to make it easier for beginners