@geut/staty

Build a proxy-state from plain objects

Usage no npm install needed!

<script type="module">
  import geutStaty from 'https://cdn.skypack.dev/@geut/staty';
</script>

README

staty

Build a proxy-state from plain objects

Build Status JavaScript Style Guide standard-readme compliant

Made by GEUT

Install

$ npm install @geut/staty

Usage

import { staty, subscribe, snapshot } from '@geut/staty'

const state = staty({
  count: 0
})

console.log(snapshot(state)) // { count: 0 }

subscribe(state, () => {
  console.log(state) // { count: 1 }
})

subscribe(state, () => {
  console.log(state.count) // 1
}, { filter: 'count' })

// filter multiple values
subscribe(state, () => {
  console.log(state.count) // 1
}, { filter: ['count'] })

state.count++

Issues

:bug: If you found an issue we encourage you to report it on github. Please specify your OS and the actions to reproduce it.

Contributing

:busts_in_silhouette: Ideas and contributions to the project are welcome. You must follow this guideline.

License

MIT © A GEUT project