Skip to content

Added custom createSnapshot support #291

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

Closed
wants to merge 19 commits into from

Conversation

trickstival
Copy link
Collaborator

@trickstival trickstival commented Jun 12, 2019

Hey! Here's my implementation of the custom createSnapshot func.
After 2 hours I got it working.

closes #240

I hope it's a good implementation, but if not just tell me a better one in the PR review.

@posva
Copy link
Member

posva commented Jun 13, 2019

Oh cool ! I should be able to give it a look in 2 weeks
I think we should be able to get rid of Vue test utils and just use Vue.extend

@trickstival
Copy link
Collaborator Author

How can I do Vue.use using Vue.extend?

I tried to use the same instance, but the first test alters the custom binding name, so I thought it would be better to scope each Global API for each test. It's just a devDependency anyway.

@posva
Copy link
Member

posva commented Jun 18, 2019

Scoping is a good idea, but if we can avoid keeping a dependency up to date, that's easier to maintain

Something like this should do

const LocalVue = Vue.extend({})
LocalVue.use(...)

@codecov-io
Copy link

codecov-io commented Jun 22, 2019

Codecov Report

Merging #291 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #291      +/-   ##
==========================================
+ Coverage   99.67%   99.67%   +<.01%     
==========================================
  Files           9        9              
  Lines         308      312       +4     
  Branches       53       54       +1     
==========================================
+ Hits          307      311       +4     
  Misses          1        1
Impacted Files Coverage Δ
packages/@posva/vuefire-core/src/utils.js 97.77% <ø> (ø) ⬆️
packages/vuefire/src/rtdb.js 100% <100%> (ø) ⬆️
packages/@posva/vuefire-core/src/index.js 100% <100%> (ø) ⬆️
packages/@posva/vuefire-core/src/rtdb.js 100% <100%> (ø) ⬆️
packages/vuefire/src/index.js 100% <100%> (ø) ⬆️

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 5636d1e...dae5e13. Read the comment docs.

@trickstival
Copy link
Collaborator Author

@posva done

@@ -41,11 +41,13 @@ function bind ({ vm, key, ref, ops }, options) {

export function firestorePlugin (
Vue,
{ bindName = '$bind', unbindName = '$unbind' } = {}
{ bindName = '$bind', unbindName = '$unbind', createSnapshot } = {}
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure about the naming because a snapshot has a particular meaning in Firestore, so let's try to find other alternatives. Maybe serializeSnapshot?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

maybe something with populate would be nice, since it's gonna get the firestore data and populate the vm.

Copy link
Member

Choose a reason for hiding this comment

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

I missed this message, sorry :(
I think we should emphasize on the fact that it transforms the data coming from Firebase before we set it on the instance, that's why I think the verb should be related to that with something like serialize or serializer

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.

We should also add the typings for vuefire

@trickstival
Copy link
Collaborator Author

@posva Added typings for createSnapshot

@trickstival
Copy link
Collaborator Author

Should #302 close this PR?

@posva
Copy link
Member

posva commented Jul 15, 2019

Yes, let's close this in favor of #302

@posva posva closed this Jul 15, 2019
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.

Allow customizing how the data is stored (id, adding properties, transforming them)
3 participants