0.1.7 • Published 7 years ago

mosaic-state v0.1.7

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

# mosaic-state

A very light-weight state management library. It allows to manage immutable state objects using cursors. Each cursor can update a individual branch in the state tree corresponding to the specified path. Cursor do not change the original state, they create a new copy of the global state, copies non-changed branches and replace values corresponding to cursor path.

Example:

var state = { msg: 'Hello' };
var root = new State(state, function(ev){
    state = ev.state;
});

console.log(root()); // {msg:'Hello'} 

var address = root.cursor('user.address');
console.log(address()); // undefined
address({
    country : 'France',
    city : 'Paris',
    street : 'rue Rivoli',
    building : 1
});
console.log(address()); // {country:'France',city:'Paris', .... }

/*
{
    user : {
        address : {
            country : 'France',
            city : 'Paris',
            street : 'rue Rivoli',
            building : 1
        }
    }
}
*/
console.log(state, root()); 
0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.0

8 years ago

0.0.2

8 years ago