@pinia/plugin-debounce
Version:
Debounce any action in your pinia 🍍 store!
22 lines • 573 B
JavaScript
// src/index.ts
var PiniaDebounce = (debounce) => ({ options, store }) => {
const { debounce: debounceOptions } = options;
if (debounceOptions) {
return Object.keys(debounceOptions).reduce(
(debouncedActions, action) => {
const args = [store[action]].concat(debounceOptions[action]);
debouncedActions[action] = debounce.apply(
null,
// @ts-expect-error: wrong array type
args
);
return debouncedActions;
},
{}
);
}
};
export {
PiniaDebounce
};
//# sourceMappingURL=index.js.map