-
-
Notifications
You must be signed in to change notification settings - Fork 345
bindFirebaseRef is not idempotent #306
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
Comments
I'm bad at reading Changelog https://github.com/vuejs/vuefire/blob/master/CHANGELOG.md#breaking-changes |
Actually, works for objects but not for arrays. So a valid issue |
This is tracked at #83 |
It was removed so it has to be added back! It's a breaking change that wasn't listed because I do plan to add it but I should indeed mention |
In 2.3.0, bindFirebaseRef was idempotent. We could simply call it in component created and call it a day. No matter how many times that page content was displayed, it showed the data fetched first time only
https://deploy-preview-308--roboclub.netlify.com/news
Switch between projects, team, and news. Only once the data is fetched and shown. And switching the navigation is as expected where the previously loaded data is retained.
After upgrading to 3.1.0, not only the data is removed and hence refetched, the bound property is first set to null, which breaks the contract of getters assumption of pre-existing data.
https://deploy-preview-323--roboclub.netlify.com/news
Try switching between projects, news and team and notice every time, data is refetched. And also, team page is broken after switching 2nd time because team property is set to null.
This forces developers to write code like this
This is needless defensive coding and error prone as it depdends on state value. Also, since team is set to null, the condition changes to
state.team && state.team.length
which is all the more ugly.Furthermore, checking the state before setting reference disables any chance of changing the reference by adding filter, etc as in both case there'll be data in state and you can't return in that case. So, an extra property is needed to store which reference is currently bound to the state.
Note that this issue is not same as previously open issues as they are from about 2017 or so while this behaviour was introduced in 3.x and 2.3.0 was working fine as shown in the demos above
The text was updated successfully, but these errors were encountered: