nexstate
v8.0.1
Published
An ESNext state management library inspired by Redux.
Downloads
27
Readme
nexstate
A simple and decentralized state management library.
Demo
You can try the demo here.
Installation
npm i nexstate
Documentation
You can find documentation here.
Example
import { Store } from 'nexstate/nexstate.js';
class CounterStore extends Store {
count = 0;
increment() {
this.setState(() => (this.count += 1));
}
}
const counterStore = new CounterStore();
const subscriptionController = new AbortController();
counterStore.runAndSubscribe(() => console.log(counterStore.count), {
signal: subscriptionController.signal,
});
counterStore.increment();
counterStore.increment();
setTimeout(() => subscriptionController.abort());