Note how we can use the update method to either provide a new value, or we can provide a reducer to provide a value that is based on its current value.
Easy to do async updates
Quick fact, with ConanJs you won't need boilerplate code to deal with asynchronous code.
Let's add two buttons to show async updates to the value.
functionrender() {return (<div> yetAnotherCounter$.renderLive ( (counterValue)=>(<h1>{counterValue}</h1>) )<button onClick={()=>yetAnotherCounter$.do.update(3)}> setValueTo3</button><button onClick={()=>yetAnotherCounter$.do.update(current=>++current)}> increase by one</button><button onClick={()=>yetAnotherCounter$.do.updateAsap( Asaps.delayed(3,1000) )}> setValueTo3 - asnyc</button><button onClick={()=>yetAnotherCounter$.do.updateAsap( Asaps.delayed(current=>++current,1000) )}> increase by one - async</button></div>)}
Easy to derive and compose state
Let's filter only even numbers, and double the current value of the state