Skip to content

Let's manage ze schät: a different approach to state management WIP

License

Notifications You must be signed in to change notification settings

SaulDoesCode/schtat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Schtät is a state manager pronounced sh-tate

NOTE: This is still a WIP, so there may be issues

Build Status

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.

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)

About

Let's manage ze schät: a different approach to state management WIP

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published