-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Apply lazy-hydrate on category page #3344
Apply lazy-hydrate on category page #3344
Conversation
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.
We need to deal with ssrProducts
local variable - remove it from Category.vue leve; otherwise it's cool
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.
If I understand correctly
initialStateFilter
removes certain STORES from Vuex completelyinitialStateFilterDefaults
sets certain FIELDS to their initial values, right?
I'm wondering if we could somehow merge this functionalities and always set defaults for fields in initialStateFilter. Amount of additional code will be barely noticeable and won't affect performance at all. in return we will cut off the complexity
Yeah this is how it works. You are right, we can set always initial values instead of removing them. I did this in that way just because I wanted to avoid potential errors / BC-breaks, but I'll check that later. |
39a0350
to
34aa9bf
Compare
Ok, I've spent some time on it and I even removed this local-variable-way hack @pkarw . Actually everything works via vuex (getters). It was possible because I've changed the way of the filtering |
OK, for me it's fine! we need some @alinadivante on QA + @patzick final approval |
@andrzejewsky just one more thing :-) can we enable this lazy loading feature only if config variable like: config.products..useLazyLoading? |
I started testing it today, but I will continue on Friday. Just write here if any others changes will be applied and what I should take into account during testing :) |
2b03048
to
221e78f
Compare
221e78f
to
261b15c
Compare
@pkarw I added option |
Cool, thanks! Waiting for @alinadivante feedback before we merge it in |
5887099
to
261b15c
Compare
for me it works good :) |
Ok! I’m merging it in |
So @andrzejewsky the next challenge will be to optimize the product page ;) but first @patzick must finish his refactoring effort on it |
Great job! Thanks! |
Related issues
closes #3327
Short description and why it's useful
This is a PoC of introducing lazy-hydrate for category pages. I had to face many issues with that. First of all the goal was to remove
category-next.products
from__INITIAL_STATE__
but it causes lack of reactivity in the vuex so theproducts
field will not be refreshed. Second one - SSR rendering - theasyncData
is calling before components were rendered and it stores the products in the vuex state that you have deleted beforehand.... and even more...let me explain what I did and why:
state
- I've introducedfilterInitialState
which uses new option in the configinitialStateFilterDefaults
that includes fields that will be set to their default values I used new option because we might need a possibility to remove totally some field, soinitialStateFilter
still works as before.initialStateFilterDefaults
), so there is no data in the state but we actually have fetched products so... I stored them in the just ordinary variablessrProducts
and if it's a SSR, it uses this variable, otherwise - read the data from getter (computed propertycategoryProducts
)The rest of code should be understandable. I know it's a bit hacky not it does work. I've not noticed a big difference in the lighthouse, but I tested this only on the dev environment. I have to admit that it reduces page size by ~40-44% though.
Let me know guys what you think.
Which environment this relates to
develop
branch and want to merge it back todevelop
release
branch and want to merge it back torelease
hotfix
ormaster
branch and want to merge it back tohotfix
Upgrade Notes and Changelog
Contribution and currently important rules acceptance