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(nuxt): move loading api behind hooks #24010

Merged
merged 28 commits into from Dec 19, 2023
Merged

Conversation

huang-julien
Copy link
Member

@huang-julien huang-julien commented Oct 28, 2023

πŸ”— Linked issue

resolve #15232
resolve #23568
resolves #14221

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Hi πŸ‘‹
This PR moves the loading mechanism behind nuxt hooks and bring some improvements to NuxtLoadingIndicator.

1. New hooks

loading states are now triggered by page:loading:start and page:loading:end (their callHook are not awaited for perf reasons)

2. useLoadingIndicator is now exported and auto-imported

It keeps local refs to handle the loading state. The loading state hasn't been moved behind a plugin or a global var to avoid having to compute it when not needed.
useLoadingIndicator hook into page:loading:start and page:loading:end to know when the loading state changes

3. Controllable NuxtLoadingIndicator

A request from some users was to be able to control the loading indicator. Since we now expose useLoadingIndicator within NuxtLoadingIndicator, users can trigger the start function or simply call the new hooks to control the state.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • TODO: I have updated the documentation accordingly.
  • TODO: Tests ?

@stackblitz
Copy link

stackblitz bot commented Oct 28, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@nuxt-studio
Copy link

nuxt-studio bot commented Oct 29, 2023

βœ… Live Preview ready!

Name Edit Preview Latest Commit
Nuxt Docs Edit on Studio β†—οΈŽ View Live Preview 71c4362

@huang-julien huang-julien marked this pull request as ready for review October 29, 2023 14:49
@huang-julien huang-julien marked this pull request as draft November 1, 2023 16:01
@huang-julien huang-julien marked this pull request as ready for review November 1, 2023 16:40
@divine
Copy link
Contributor

divine commented Nov 9, 2023

Hello,

Sorry to bump, is there any ETA for this feature to be merged?

cc @danielroe

Thanks!

@danielroe
Copy link
Member

It'll need to wait for the next minor.

@divine
Copy link
Contributor

divine commented Dec 2, 2023

Hello,

Sorry to bump, since the minor is coming soon does it mean this can be merged?

Thanks!

@warrenseine
Copy link

I'm also eagerly waiting for this fix. I have confirmed it works as expected and have been using a custom build including this patch in production for a few weeks now. I'd love to see it merged.

@Atinux
Copy link
Member

Atinux commented Dec 14, 2023

Could you also link to the useLoadingIndicator() page from https://nuxt.com/docs/api/components/nuxt-loading-indicator as well?

@Atinux
Copy link
Member

Atinux commented Dec 14, 2023

Is it possible to trigger a release to test this on a project @danielroe ?

@danielroe
Copy link
Member

/trigger release

Copy link
Contributor

πŸš€ Release triggered! You can now install nuxt@npm:nuxt-nightly@pr-24010

@danielroe danielroe requested a review from pi0 December 15, 2023 16:09
@Atinux
Copy link
Member

Atinux commented Dec 16, 2023

/trigger release

Copy link
Contributor

πŸš€ Release triggered! You can now install nuxt@npm:nuxt-nightly@pr-24010

@danielroe danielroe merged commit 9cd6c92 into main Dec 19, 2023
33 of 36 checks passed
@danielroe danielroe changed the title feat(nuxt)!: move loading api behind hooks feat(nuxt): move loading api behind hooks Dec 19, 2023
@danielroe danielroe deleted the feat/unified-loading-pi branch December 19, 2023 10:18
This was referenced Dec 19, 2023
@BenAkroyd
Copy link

⚠️ Breaking change (fix or feature that would cause existing functionality to change)
^ This is checked in the PR description. Was this in err? If not, would you mind explicitly identifying the breaking change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants