4 ms·
This is the approach that many ClojureScript frameworks take, and I find it to be a much more elegant approach than Flux proper. You use a single, immutable da
by lewisl9029 11y ago
This is the approach that many ClojureScript frameworks take, and I find it to be a much more elegant approach than Flux proper.
You use a single, immutable data structure to store your application state, and components use functional lenses to look into the part of the state they're dependent on and listen for changes.
In doing so, you get a free application history stack and deltas (for undo/redo, offline/online sync and some powerful debugging capabilities), extremely efficient shouldComponentUpdate implementations for all components, and opportunities for many more advanced optimizations like batching updates for rendering on requestAnimationFrame.
Check out Om if you'd like to take a look at the original ClojureScript implementation, or Morearty.js if you're interested in a pure JS alternative.
https://github.com/moreartyjs/moreartyjs https://github.com/moreartyjs/moreartyjs
https://github.com/omcljs/om https://github.com/omcljs/om