https://github.com/soenkekluth/object-store-state
observable stateful object store
https://github.com/soenkekluth/object-store-state
dot-notation key-value state store
Last synced: 7 months ago
JSON representation
observable stateful object store
- Host: GitHub
- URL: https://github.com/soenkekluth/object-store-state
- Owner: soenkekluth
- License: mit
- Created: 2017-03-24T22:53:44.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T08:50:12.000Z (about 2 years ago)
- Last Synced: 2025-05-16T22:35:10.772Z (8 months ago)
- Topics: dot-notation, key-value, state, store
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/object-store-state
- Size: 89.8 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/soenkekluth/object-store-state)
# object-store-state
> observable stateful object store
## Usage
```js
const store = require('object-store-state').store;
// es6
import { store } from 'object-store-state';
// create a Store instance with an initial state
const myStore = store({foo: 'bar'});
console.log(myStore.get('foo'));
//=> 'bar'
myStore.set('awesome', true);
console.log(myStore.get('awesome'));
//=> true
// Use dot-notation to access nested properties
myStore.set('bar.baz', true);
console.log(myStore.get('bar'));
//=> {baz: true}
myStore.delete('awesome');
console.log(myStore.get('awesome'));
//=> null
myStore.set('my.super.obj', {foo: 'bar'});
console.log(myStore.get('my.super.obj'));
//=> { foo: 'bar' }
myStore.subscribe('my.super.obj', function(e){
console.log(e.type, e.value);
//=> my.super.obj { foo: 'hans' }
});
myStore.set('my.super.obj', {foo: 'hans'});
console.log(myStore.toJSON());
/* => {
"foo": "bar",
"bar": {
"baz": true
},
"my": {
"super": {
"obj": {
"foo": "hans"
}
}
}
}
*/
```
## API
## License
MIT