https://github.com/sauldoescode/schtat
Let's manage ze schät: a different approach to state management WIP
https://github.com/sauldoescode/schtat
library state-management statemanager
Last synced: 5 months ago
JSON representation
Let's manage ze schät: a different approach to state management WIP
- Host: GitHub
- URL: https://github.com/sauldoescode/schtat
- Owner: SaulDoesCode
- License: mit
- Created: 2018-05-01T20:56:54.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-23T13:49:57.000Z (over 7 years ago)
- Last Synced: 2025-08-17T16:44:15.629Z (6 months ago)
- Topics: library, state-management, statemanager
- Language: JavaScript
- Size: 15.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Schtät is a state manager pronounced sh-tate
NOTE: This is still a WIP, so there may be issues
[](https://travis-ci.org/SaulDoesCode/schtat)
Schtät is a different approach to state management
that takes a flow/pipeline approach to mutations,
which, then get distributed to various bindings.
(like the observer pattern but with flow and bouncers)
### How Do We manage ze schtät?
Wis a state factory representing a single value
that can be consumed, mutated, pre-screened, screened and observed at any stage
(event sourcing is also possible) to produce consumable views (computed values),
or binds which synchronize a state or state view with a property on any object.
```js
import state from 'schat.js'
const counter = state({
val: 0,
screen: val => typeof val === 'number' && !isNaN(val) && val % 1 === 0,
mut (val) {
console.log(val)
},
fail (val, err) {
throw new Error(`Value: ${val}, Issue: ${err}`)
},
views: {
display: val => `The current counter value is ${val}.`
}
})
const counterDisplay = document.querySelector('div.counter')
counter.bind(counterDisplay, 'textContent', 'display')
setInterval(() => counter.mutate(val => val + 1), 500)
```