zustand-debounce
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

Zustand Debounce

zustand-debounce is a library that extends the capabilities of Zustand to provide a JSON state storage system with delayed (debounced) writing to storage. With this tool, you can reduce the number of write operations to storage by delaying and grouping them.

✅ 🐙 Lightweight!! 367 B gzipped.

✅ 🚀 Easy integration into your projects.

✅ 🕒 Customize the debounce time according to your needs.

✅ 🔄 Avoid frequent writes to storage.

✅ Full TypeScript support.

Installation

pnpm add zustand-debounce
# o
npm install zustand-debounce
# o
yarn add zustand-debounce

Usage

import { createDebouncedJSONStorage } from "zustand-debounce"

// Replace createJSONStorage with createDebouncedJSONStorage
// Experience the enchantment of delayed writes ✨
export const usePersonStore = create<PersonState & Actions>()(
  persist(storeApi, {
    name: "person-storage",
    storage: createDebouncedJSONStorage(firebaseStorage, {
      debounceTime: 2000, // Debounce time in milliseconds ⏳
    }),
  }),
)

Contributions

Contributions are welcome. If you find an issue or have an idea to improve zustand-debounce, feel free to open an issue or submit a pull request.

License 📜

Licensed as MIT open source.


with 💖 by AbianS

Package Sidebar

Install

npm i zustand-debounce

Weekly Downloads

19

Version

1.1.2

License

MIT

Unpacked Size

4.69 kB

Total Files

5

Last publish

Collaborators

  • abians7