Options
All
  • Public
  • Public/Protected
  • All
Menu

nexstate

nex logo

nexstate

A simple and decentralized state management library.

npm version npm downloads github issues license

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());

Generated using TypeDoc