observable-path-store

1.0.1 • Public • Published

Observable Path Store

A key value observable pathed store

var store = new ObservablePathStore()
store.modify('animals.cats', 'Felix')
store.modify('animals.dogs', 'Sultan')
assert.equal(store.get('animals.dogs'), 'Sultan')
store.subscribe('animals', (value) => {
  assert.equal(value, 'Felix')
  done()
})
store.fire('animals.cats')

How to inherit

It is usually better to use composition but if prefer you can inherit the class

class A extends ObservablePathStore {
}
var store = new A()
store.modify('animals', 'Animals')
assert(store.get('animals'), 'Animals')

Public API

ObservablePathStore.prototype = {
  subscribe: function (path, fn) {},
  unsubscribe: function (path, fn) {},
  fire: function (path) {},
  modify: function (path, value, fire = false) {},
  get: function (path) {}
}

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i observable-path-store

      Weekly Downloads

      1

      Version

      1.0.1

      License

      ISC

      Last publish

      Collaborators

      • batiste