npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

mobx-keys-store

1.1.0 • Public • Published

mobx-keys-store

Build Status Dependency Status devDependency Status

Installation

npm install mobx-keys-store

Usage

import KeysStore from 'mobx-keys-store';
 
const initialState = {};
const store = new KeysStore(initialState);
 
/*
 * Observe the store and its properties
 */
 
store.setItem('foo', 1);
store.increaseItem('foo');

Documentation

Constructor

The constructor can receive an object with initial keys.

Store methods

setItem(name, value)

setItem adds a new or updates an existing property.

removeItem(name)

removeItem removes a property from the store.

increaseItem(name, [amount=1])

increaseItem will increase the value of the selected property.

decreaseItem(name, [amount=1])

decreaseItem will decrease the value of the selected property

Note

If you try to observe a property which doesn't yet exist, you might not be notified once the property is added. That's why it might be best to add the property to the initial store values.

License

The MIT License

© 2016 Infinum Inc.

install

npm i mobx-keys-store

Downloadsweekly downloads

14

version

1.1.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
Report a vulnerability