1.1.1 • Published 5 days ago

keenstore v1.1.1

Weekly downloads
-
License
ISC
Repository
github
Last release
5 days ago

keenstore

Zero-dependency data store offering subscription to changes

Installation

npm i keenstore

Usage

import {Store} from 'keenstore';

let store = new Store({value: 42});

// Read the data in the store
store.getState(); // > { value: 42 }

// Subscribe to updates in the store and add a callback for each
// update via `store.setState()`
store.onUpdate((nextState, prevState) => {
    console.log(nextState.value, prevState.value);
});

// Update the data in the store and trigger the update callbacks
store.setState({value: 100});
// To unsubscribe an update callback from the store use the
// returned value of the `store.onUpdate()` method
let unsubscribe = store.onUpdate((nextState, prevState) => {
    console.log(nextState.value, prevState.value);
});

unsubscribe();

See also

1.1.1

5 days ago

1.1.0

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago