ventileco-store
v1.0.4
Published
Ventileco Store is a lightweight global state management library. You can install it using the following command:
Readme
ventileco-store
Ventileco Store is a lightweight global state management library. You can install it using the following command:
Getting started
npm install ventileco-storepnpm add ventileco-storeIntroduction
Ventileco Store provides efficient state management with a simple API and lightweight performance. It allows you to manage global state easily without the complexity of Redux. With a package size of less than 5KB, it ensures minimal impact on your application.
Features
Lightweight: Manage global state with minimal code
Simple API: Intuitive and easy to use
TypeScript Support: Fully compatible with TypeScript
Works with React, Vanilla JS, ...: Usable across different environments
Usage
// Creating Stores (Recommended to Be Defined Once at the Root Level)
// Basic store
export const countStore = new Store(1)
// Object store
export const nameStore = new Store({ firstName: 'Geonwoo', lastName: 'Park' })
// Persisted store with session storage
export const primitiveStore = new Store(100, [
new SessionStoragePersist('primitive'),
])
// Persisted store with local storage
export const objectStore = new Store({ isOpen: false, count: 200 }, [
new LocalStoragePersist('object'),
])// Accessing store states
countStore.getState()
// Updating store states
countStore.setState((prev) => prev + 1)// Using a primitive store in a React component
const [value, setValue] = useStore(primitiveStore, (state) => state)
// Using an object store and selecting a specific property (count)
const [count, setCount] = useStore(objectStore, (state) => state.count)🌷 NPM URL
