pinia-plugin-loading

Auto loading data binding plugin for pinia. You don't need to write showLoading and hideLoading any more.
1,337 12
Install
npm install pinia-plugin-loading
Latest Version:2.0.0
Vue:2 · 3
License:MIT
Last Updated:Dec 29, 2022
Links: GitHub  ·  npm
Maintainer: sanpiao

Pinia logo Pinia Plugin Loading

Auto loading data binding plugin for pinia. You don't need to write showLoading or hideLoading any more.

Installation

npm install pinia-plugin-loading

or

yarn add pinia-plugin-loading

Usage

import { createPinia } from 'pinia'
import { PiniaLoading } from 'pinia-plugin-loading'
const pinia = createPinia()
pinia.use(PiniaLoading)

All actions in your stores now have a matching, reactive boolean in $loading that indicates whether the action is pending or not.

Example

import { defineStore } from 'pinia'
export const useStore = defineStore('main', {
  state: () => {
    return {
      info: null
    }
  },
  actions: {
    async fetchData() {
      this.info = await request('/api')
    }
  }
})
<template>
  <div>
    <loading v-if="store.$loading.fetchData" message="Loading…" />
  </div>
</template>

<script lang="ts" setup>
import { useStore } from '@/store'
const store = useStore()
</script>

License

MIT

Related Packages

pinia-plugin-created

create created lifecycle method in your pinia 🍍 store!

284 0
pinia-persistedstate-plugin

A pinia plugin like vuex-persistedstate.

8,546
pinia-plugin-router

A pinia plugin that help use vue-router in pinia

4,356
pinia-persistedstate

For vue3. Persist and rehydrate your Pinia state between page reloads.

3,857 15
pinia-plugin-firestore-sync

Sync your pinia state and firestore document at ease!

442

Version History

Version Released Vue License
2.0.0 ^2.0.0 || >=3.0.0 MIT
1.0.9 ^2.0.0 || >=3.0.0 MIT
1.0.8 ^2.0.0 || >=3.0.0 MIT
1.0.7 ^2.0.0 || >=3.0.0 MIT
1.0.6 ^2.0.0 || >=3.0.0 MIT