27 lines
590 B
JavaScript
27 lines
590 B
JavaScript
import Store from '../src/datastore'
|
|
|
|
const store = new Store({
|
|
path: process.cwd() + '/examples/foo.json'
|
|
})
|
|
|
|
const foo = {bar:3, bash:{bin:2,what:5}}
|
|
|
|
store.set('foo',foo)
|
|
// store.set('foo.bash',3)
|
|
// store.set('foo.what',5)
|
|
|
|
console.log('simple get', store.get('foo'))
|
|
|
|
console.log('current observers', store.getObs())
|
|
|
|
// let temp = store.setObs('foo.bar')
|
|
|
|
let obs = store.setObs('foo.bar')
|
|
|
|
obs.subscribe(val=>console.log('foo bar handler 1',val))
|
|
obs.subscribe(val=>console.log('foo bar handler 2',val))
|
|
|
|
console.log('current observers', store._observers)
|
|
|
|
store.set('foo.bar',8)
|