A simple and decentralized state management library.
You can try the demo here.
npm i nexstate
You can find documentation here.
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());
Generated using TypeDoc