Vue-Wait: Global Loading Management

1.5.3 · active · verified Tue Apr 21

Vue-Wait is a Vue plugin designed for comprehensive global loading state management within Vue applications, optionally integrating with Vuex. It simplifies the handling of multiple concurrent loading processes, preventing UI conflicts and providing clear visual feedback to users. The current stable version, 1.5.3, includes important updates like Vue 3 support, released in v1.5.0, demonstrating ongoing maintenance and adaptability to the evolving Vue ecosystem. The library distinguishes itself by offering both a declarative component (`<v-wait>`) and a directive (`v-wait`) for displaying loading indicators, alongside a programmatic API (`$wait.start()`, `$wait.end()`) for granular control over individual loading states. Additionally, it provides features for progress indication and configurable Vuex integration, making it a flexible solution for various application sizes and complexities. Its core idea relies on an array-based system to track active wait states, making it intuitive to manage.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates the setup of Vue-Wait in a Vue 3 application, showing how to instantiate and register the plugin globally. It also includes commented-out example Vue component code to illustrate how to use the `<v-wait>` component and the `$wait` service to manage and display loading states for an asynchronous operation.

import { createApp } from 'vue'
import { createVueWait } from 'vue-wait'
import App from './App.vue'

const VueWait = createVueWait()

const app = createApp(App)
app.use(VueWait)
app.mount('#app')

// Example component usage:
// <template>
//   <v-wait for="my list is to load">
//     <template slot="waiting">
//       <div>Loading the list...</div>
//     </template>
//     <ul>
//       <li v-for="item in myList" :key="item">{{ item }}</li>
//     </ul>
//   </v-wait>
// </template>

// <script>
// export default {
//   data() {
//     return {
//       myList: []
//     }
//   },
//   async created() {
//     this.$wait.start('my list is to load');
//     // Simulate an async fetch
//     await new Promise(resolve => setTimeout(resolve, 2000));
//     this.myList = ['Item 1', 'Item 2', 'Item 3'];
//     this.$wait.end('my list is to load');
//   },
// };
// </script>

view raw JSON →