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

<NuxtLoadingIndicator> and loading events #14221

Closed
pi0 opened this issue Jun 23, 2022 · 12 comments · Fixed by #24010
Closed

<NuxtLoadingIndicator> and loading events #14221

pi0 opened this issue Jun 23, 2022 · 12 comments · Fixed by #24010

Comments

@pi0
Copy link
Member

pi0 commented Jun 23, 2022

When <NuxtLoadingIndicator> landed, we should introduce a controller API (TODO: issue pending in framework). This should address a long time waiting for a feature for Nuxt 2 (#7893, nuxt-community/axios-module#247 (comment)) in a consistent way with Nuxt 3.

@danielroe danielroe transferred this issue from nuxt/bridge Aug 22, 2022
@acidjazz
Copy link
Contributor

curious - are we going to have any methodology/documentation to hooking this into useFetch and/or $fetch so that our indicator is in line our external calls?

@danielroe danielroe added the 3.x label Jan 19, 2023
@danielroe danielroe transferred this issue from nuxt/framework Jan 19, 2023
@acidjazz
Copy link
Contributor

acidjazz commented Jan 19, 2023

I'd like to share a hack I've been using just to see if it's useful:

I have an Api lib/class I use to interact with my API that wraps around ohmyfetch - and from it i set fetchOptions to fire off my own start/finish cal hooks:

    fetchOptions.onRequest = () => this.nuxtApp.callHook('page:start')
    fetchOptions.onResponse = () => this.nuxtApp.callHook('page:finish')

I get multiple loading indicators for each call if its multiple unlike v2 which would combine them - but it works!

demonstrated in my laravel+nuxtjs template https://github.com/fumeapp/laranuxt

@snowdream
Copy link

I'd like to share a hack I've been using just to see if it's useful:

I have an Api lib/class I use to interact with my API that wraps around ohmyfetch - and from it i set fetchOptions to fire off my own start/finish cal hooks:

    fetchOptions.onRequest = () => this.nuxtApp.callHook('page:start')
    fetchOptions.onResponse = () => this.nuxtApp.callHook('page:finish')

I get multiple loading indicators for each call if its multiple unlike v2 which would combine them - but it works!

demonstrated in my laravel+nuxtjs template https://github.com/fumeapp/laranuxt

It works!

Thank you !

@manniL
Copy link
Member

manniL commented Mar 4, 2023

See #16351 for other options, as calling hooks could have other side effects.

@acidjazz
Copy link
Contributor

acidjazz commented Mar 5, 2023

sorry @manniL looking through #16351 is there an option you prefer?

@mrleblanc101
Copy link

Hi,
Should this get prioritized, fast tracked ? This would bring feature parity with Nuxt 2. Also, maybe I'm wrong, but it does not seem like an overly complicated thing to implement ?

@manniL
Copy link
Member

manniL commented Mar 14, 2023

@mrleblanc101 A PR is absolutely welcome! As this is already possible in userland (see answer in #16351), the priority is set to "nice-to-have" ☺️

@acidjazz
Copy link
Contributor

Preferably a way to do this so that multiple fetch calls balance out to one single load bar - how nuxt2 worked.

@mrleblanc101
Copy link

@manniL I don't understand your workaround. You say callHook can have dangerous side effect

See #16351 for other options, as calling hooks could have other side effects.

You link to another issue where you also mention to use callHook without saying what are the side effect or an alternative without side effects 🤔

You could call the page:start/page:finish hook as needed but that might have unwanted side effects.

What is the solution in user land without side effect ?

@acidjazz
Copy link
Contributor

@mrleblanc101 I think he means that current solution for now w/ the potential side effect which lowers the priority of this feature

@mrleblanc101
Copy link

mrleblanc101 commented Mar 14, 2023

@acidjazz Not sure. He says:
See #16351 for "other options".

Why would I go see #16351 from 14 days ago since your message from 2 months ago in this very own thread has the same solution.

@manniL
Copy link
Member

manniL commented Mar 15, 2023

I meant specifically an own implementation approach as @Gaspadlo did #16351 (comment) for now. Sorry if that was unclear.

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

Successfully merging a pull request may close this issue.

6 participants