@begin/store

1.0.0 • Public • Published

store

Simple store.

Usage

import Store from 'https://unpkg.com/@begin/store'
// Initialize the store ( you can pass an initial state object )
const store = Store({ lyrics: 'Yah yah yah, yah, yah' })
// or
store.initialize({ lyrics: 'Yah yah yah, yah, yah' })
// Subscribe to the store by passing the function you want to be called when state changes
// Pass an array of keys you want to be notified about when they change
store.subscribe(update, [ 'lyrics' ])
store.a = 'Woo hah, I got you all in check!'
function update(state) {
  console.log(state) // { lyrics: 'Woo hah, I got you all in check!' }
}
// clean up later with store.unsubscribe(update)

Readme

Keywords

none

Package Sidebar

Install

npm i @begin/store

Weekly Downloads

1

Version

1.0.0

License

Apache-2.0

Unpacked Size

16.5 kB

Total Files

5

Last publish

Collaborators

  • ryanblock
  • dam
  • brianleroux
  • beginci