nexstate
TypeScript icon, indicating that this package has built-in type declarations

8.0.1 • Public • Published

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

Package Sidebar

Install

npm i nexstate

Weekly Downloads

5

Version

8.0.1

License

MIT

Unpacked Size

4.63 kB

Total Files

5

Last publish

Collaborators

  • hawmex