tiny-state-x
v1.0.0
Published
Tiny framework-agnostic state manager
Readme
Tiny State X
A tiny, framework-agnostic state manager with middleware, selectors, and persistence.
Features
- Minimal (~1KB)
- Framework agnostic
- Selectors (performance optimized)
- Middleware support
- Persistence (localStorage)
- React + Angular support
Installation
npm install tiny-state-x
## Basic Usage
import { createStore } from 'tiny-state-x';
const store = createStore({ count: 0 });
store.subscribe((state) => {
console.log(state);
});
store.setState({ count: 1 });
## Selector:
store.subscribe(
(count) => console.log(count),
(state) => state.count
);
## Middlewate:
import { devtools } from 'tiny-state-x';
store.use(devtools('App'));
## Persistance:
import { persist, loadPersisted } from 'tiny-state-x';
const store = createStore(
loadPersisted('app', { count: 0 })
);
store.use(persist('app'));
## Angular:
const ngStore = createAngularStore(store);
ngStore.state$.subscribe(console.log);
## React:
import { useStore } from 'tiny-state-x';
const count = useStore(store, s => s.count);
