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): tryUseNuxtApp composable #25031

Merged
merged 5 commits into from Jan 18, 2024

Conversation

daniluk4000
Copy link
Contributor

πŸ”— Linked issue

#24681

❓ 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

This PR adds new tryUseNuxtApp alias for useNuxtApp which will return null instead of throwing an exception. This also matches with existing tryUseNuxt composable.

Resolves #24681

I have also decided not to create separate page in docs for this one.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have added tests (if possible).
  • I have updated the documentation accordingly.

Copy link

stackblitz bot commented Jan 3, 2024

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

Copy link

nuxt-studio bot commented Jan 3, 2024

βœ… Live Preview ready!

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

@github-actions github-actions bot added the 3.x label Jan 3, 2024
@danielroe
Copy link
Member

Nice work.

Makes sense :D

Co-authored-by: Daniel Roe <daniel@roe.dev>
Co-authored-by: Damian GΕ‚owala <damian.glowala.rebkow@gmail.com>
@danielroe danielroe added this to the 3.10 milestone Jan 3, 2024
@danielroe danielroe merged commit 6b651cf into nuxt:main Jan 18, 2024
36 checks passed
@github-actions github-actions bot mentioned this pull request Jan 18, 2024
@peteromano
Copy link

Hi guys, just curious:

Was this meant for modules and integrations? I think nuxt storybook temporarily throws this exception when booting up, and seems like this would help

@daniluk4000
Copy link
Contributor Author

Hi guys, just curious:

Was this meant for modules and integrations? I think nuxt storybook temporarily throws this exception when booting up, and seems like this would help

Yo. I was using this for composables that can be run in modules/plugins/components/async context. This meant to be used whenever dev is OK that he could not have context currently and have alternative to use instead.

I dont know about Storybook issue, but if it needs that context, tryUseNuxtApp wouldn't help much.

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

Successfully merging this pull request may close these issues.

Improve callWithNuxt DX
4 participants