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

Add asyncData() support for the subcomponents #970

Closed
pkarw opened this issue Mar 31, 2018 · 0 comments
Closed

Add asyncData() support for the subcomponents #970

pkarw opened this issue Mar 31, 2018 · 0 comments
Labels
question If you are not sure how sth works or want discuss someting refactor Code refactoring

Comments

@pkarw
Copy link
Collaborator

pkarw commented Mar 31, 2018

Somehow related to:
nuxt/nuxt#32 (comment)

https://nuxtjs.org/faq/async-data-components/

Why loading the data into core/pages is not optimal solution? Because it breaks the SRP principle - when You like to add your let's say ProductDetails component to other page You need to somehow duplicate the data fetching logic. Of course, we can move the more-sophisticated data fetching logic solely to Vuex actions to simplify the Components logic as a first step

We need to modify:
https://github.com/DivanteLtd/vue-storefront/blob/9be57858de241ab7f0d39b999cedae137fb0b40b/core/client-entry.js#L27

To support not only mixins but also components. This will allow us to refactor the core/pages to more granular components like: ProductDetails etc.

The sub-components could be more self-sufficient then and take the responsibility for it's own state management - but not only!

Open questions:

  • how about properties support (the asyncData is static - doesn't have access to this)?

Roadmap:

  • add asyncData support for child components,
  • simplyify the data fetching logic for Product and Category pages - moving the fetchData logick to Vuex action
  • create more granular components that can load product details, list of products using only properties - without router access
  • try to refactor core/pages/Product and core/pages/Category using these components
@pkarw pkarw added question If you are not sure how sth works or want discuss someting refactor Code refactoring labels Mar 31, 2018
@pkarw pkarw closed this as completed Sep 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question If you are not sure how sth works or want discuss someting refactor Code refactoring
Projects
None yet
Development

No branches or pull requests

1 participant