README
Pinia Debounce
Debounce any action in your pinia 🍍 store!
This is also a very good example of how to create a pinia plugin and how to type it.
Installation
npm install @pinia/plugin-debounce
You also need to use a debounce
function like lodash.debounce or ts-debounce
Usage
import { debounce } from 'ts-debounce'
import { PiniaDebounce } from '@pinia/plugin-debounce'
// Pass the plugin to your application's pinia plugin
pinia.use(PiniaDebounce(debounce))
You can then use a debounce
option in your stores:
defineStore('id', {
actions: {
someSearch() {
// ...
},
},
debounce: {
// debounce all `someSearch` calls by 300ms
someSearch: 300,
},
})