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

[feat] replace asyncData with fetch #44

Closed
wants to merge 15 commits into from
Closed

[feat] replace asyncData with fetch #44

wants to merge 15 commits into from

Conversation

anton-karlovskiy
Copy link
Member

@anton-karlovskiy anton-karlovskiy commented Feb 5, 2021

#41

@vercel
Copy link

vercel bot commented Feb 5, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/nuxt-movies/nuxt-movies/99uAvVSPCPXoSqTLhDQeuFTXtURh
✅ Preview: https://nuxt-movies-git-fork-anton-karlovskiy-perf-fetch-hook-60c667.vercel.app

pages/index.vue Outdated Show resolved Hide resolved
async asyncData({ error }) {
data() {
return {
trendingMovies: {},
Copy link
Member

Choose a reason for hiding this comment

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

Tip: For data-reuse technique, we need a global store object otherwise fetched data will be lost (refetched) when going to a page and coming back

Copy link
Member Author

Choose a reason for hiding this comment

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

@pi0 It makes sense. Thank you.

Copy link
Member Author

@anton-karlovskiy anton-karlovskiy Feb 11, 2021

Choose a reason for hiding this comment

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

@pi0 @danielroe @addyosmani
Could you please check #41 (comment)?

pages/genre/_id/movie.vue Outdated Show resolved Hide resolved
@anton-karlovskiy
Copy link
Member Author

@pi0
FYI: I added keep-alive and :keep-alive-props="{ max: 10 }".

@anton-karlovskiy
Copy link
Member Author

@pi0
FYI: I added activated hooks.

@anton-karlovskiy
Copy link
Member Author

@pi0
Could you please review 7d0c04e?
Thank you.

Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

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

I think we should move caching logic to tmdbAPI instead of doing inside page:

  • Decouples page cache from data cache
  • Allows universal caching (swr on server and client)
  • Prevent caching duplicate data in memory if two pages fetch same endpoint

@anton-karlovskiy
Copy link
Member Author

anton-karlovskiy commented Feb 25, 2021

Hi @pi0 @danielroe

Decouples page cache from data cache
Allows universal caching (SWR on server and client)
Prevent caching duplicate data in memory if two pages fetch the same endpoint

Actually, I think I have not correctly understood how to approach resolving these issues.
Could you please teach me in detail or give me some relevant articles or links to resources?
Thank you!

@anton-karlovskiy
Copy link
Member Author

@addyosmani
https://nuxt-movies-9fm7b3y46-nuxt-movies.vercel.app/ is the URL to the last deployment for now as the other PR was merged.

@anton-karlovskiy anton-karlovskiy closed this by deleting the head repository Jul 21, 2024
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.

2 participants