0.2.1 • Published 9 years ago

statestore v0.2.1

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

StateStore

a simple state manager for mvc or flux

Installation

$ npm install statestore

Usage

var StateStore = require('statestore');

var store = new StateStore({
	a: 'aaa',
	b: {
		name: 'bbb',
		child: {
			name: 'ccc',
			arr: [1, 2, 3]
		}
	}
});

var unsubscribe = store.subscribe('b.child', function handler(path, value, oldValue) {
	console.log(handler.sPath);
	console.log(store.getState('b.child'));
});

store.setState('b.child.name', 'c');
store.setState({
	a: '123',
	b: {
		name: 'bbb'
	}
});
unsubscribe();

store.subscribe('b.child.arr', function() {
	console.log(store.getState('b.child.arr'));
});
store.subscribe('b', function() {
	console.log(store.getState('b.child.arr'));
});

store.setState('b.child.arr', [1, 2, 3]);
store.setState('b.child.arr', [4, 2, 3]);

store.unsubscribeAll();

Example

a simple todo example

0.2.1

9 years ago

0.2.0

9 years ago

0.1.9

9 years ago

0.1.8

9 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago