Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[feat] useLoadingIndicator force reset function #24938

@divine

Description

@divine

Describe the feature

Hello,

As discussed in #24900.

There should be an option for useLoadingIndicator.start({ force: true }) so when it's called the Loading indicator should start from scratch.

Currently, after the page load it's not possible to manually start useLoadingIndicator because there is setTimeout which is basically preventing the start:

function _hide (isLoading: Ref<boolean>, progress: Ref<number>) {
if (import.meta.client) {
setTimeout(() => {
isLoading.value = false
setTimeout(() => { progress.value = 0 }, 400)
}, 500)
}
}

As suggested by @manniL I could use a workaround and wait 1 second

export default defineNuxtPlugin({
  // eslint-disable-next-line unused-imports/no-unused-vars
  async setup(nuxtApp) {},
  hooks: {
    // You can directly register Nuxt app runtime hooks here
    'page:loading:end': async function () {
      console.log('Calling startLoading function from a plugin!');
      await new Promise(r => setTimeout(r, 1000))
      startLoading();
    },
  },
});

Honestly, this makes loading indicator as lagging which is weird.

Thanks!

Additional information

  • Would you be willing to help implement this feature?
  • Could this feature be implemented as a module?

Final checks

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Later

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions