Mixer is a tool to mix usual variables with state
npm
npm i @watch-state/mixer
yarn
yarn add @watch-state/mixer
Or just download a minified js file here
Mixer
works like Cache
but you can mix some states and usual variables.
let count = 0
const text = new Mixer(() => {
return count++ ? (
`Updated: ${count - 1}`
) : null
})
const watcher = new Watch(() => {
console.log(
text.value ? text.value : 'First render'
)
})
// console.log('First render')
watcher.update()
// console.log('Updated: 1')
watcher.update()
// console.log('Updated: 2')
you cannot use
mixer
insidecache
, it'll be fixed in the future
If you find a bug or have a suggestion, please file an issue on GitHub.