Skip to content
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

Merged
merged 2 commits into from Jan 1, 2020
Merged

Conversation

darrelfrancis
Copy link
Contributor

to make it easier for beginners

to make it easier for beginners
@codecov-io
Copy link

codecov-io commented Dec 26, 2019

Codecov Report

Merging #536 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6c4c7ce...2f4d1c6. Read the comment docs.

Copy link
Member

@posva posva left a 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`.
Copy link
Member

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.

Copy link
Contributor Author

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.
Copy link
Member

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')

Copy link
Contributor Author

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!)

Copy link
Member

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

Copy link
Contributor Author

@darrelfrancis darrelfrancis left a 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-)

Copy link
Member

@posva posva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@posva posva merged commit ebf07d5 into vuejs:master Jan 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants