@mxweb/store
v1.1.0
Published
Lightweight reactive state management library with TTL caching, API response handling, browser storage watching, and React integration
Downloads
160
Maintainers
Readme
@mxweb/store
Lightweight reactive state management library with TTL caching, API response handling, browser storage watching, and React integration.
Features
- 🚀 Lightweight - Minimal footprint, zero unnecessary dependencies
- ⚡ Reactive - Event-based state updates with subscription system
- 🔄 TTL Caching - Automatic cache invalidation with time-to-live support
- 🌐 API Management - Built-in fetch, refetch, and debounce for API responses
- 💾 Storage Watcher - Reactive monitoring of cookies, localStorage, and sessionStorage
- ⚛️ React Integration - Context provider and hooks for seamless React usage
- 📦 TypeScript - Full type safety with comprehensive type definitions
- 🖥️ SSR Ready - Safe to use in server-side rendering environments
Installation
npm install @mxweb/store
# or
yarn add @mxweb/store
# or
pnpm add @mxweb/storeQuick Start
import { StoreBase } from "@mxweb/store";
interface AppState {
count: number;
}
class CounterStore extends StoreBase<AppState> {
constructor() {
super({ count: 0 });
}
increment() {
return this.setState({ count: this.state.count + 1 });
}
}
const store = new CounterStore();
store.onStateChange(() => console.log(store.getState()));
store.increment(); // { count: 1 }Documentation
For full documentation, API reference, and examples, visit docs.mxweb.io/store.
License
MIT © MxWeb Team
