Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.
/frameworkPublic archive

feat(nuxt): add onNuxtReady composable - #9478

Merged
pi0 merged 4 commits into
mainfrom
feat/on-nuxt-ready
Dec 5, 2022
Merged

feat(nuxt): add onNuxtReady composable#9478
pi0 merged 4 commits into
mainfrom
feat/on-nuxt-ready

Conversation

@danielroe

Copy link
Copy Markdown
Member

🔗 Linked issue

resolvesnuxt/nuxt#15719

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 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)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

This adds a new onNuxtReady composable. It allows running a callback after your app has finished initializing. It is ideal for running code that should not block the initial rendering of your app.

exportdefaultdefineNuxtPlugin(()=>{onNuxtReady(async()=>{constmyAnalyticsLibrary=awaitimport('my-big-analytics-library')// do something with myAnalyticsLibrary})})

It is 'safe' to run even after your app has initialized. In this case, then the code will be registerd to run in the next idle callback.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroedanielroe added enhancement New feature or request 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing labels Dec 2, 2022
@danielroe
danielroe requested a review from pi0December 2, 2022 20:52
@danielroedanielroe self-assigned this Dec 2, 2022
@codesandbox

Copy link
Copy Markdown

CodeSandbox logoCodeSandbox logo Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@HigherOrderLogic

Copy link
Copy Markdown
Contributor

Isn't it more ideal to make this a hook? Something like app:ready?

@danielroe

Copy link
Copy Markdown
MemberAuthor

There is already such a hook, which this composable uses internally.

pi0
pi0 approved these changes Dec 5, 2022

@pi0pi0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 💯

@pi0
pi0 merged commit 4c4249d into mainDec 5, 2022
@pi0
pi0 deleted the feat/on-nuxt-ready branch December 5, 2022 10:09
@pi0pi0 mentioned this pull request Dec 15, 2022
6 tasks
@danielroedanielroe mentioned this pull request Jan 20, 2023
danielroe added a commit that referenced this pull request Jan 21, 2023
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3.xenhancementNew feature or request🍰 p2-nice-to-havePriority 2: nothing is broken but it's worth addressing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

onNuxtReady in nuxt 3

3 participants

@danielroe@HigherOrderLogic@pi0