We wrote code with FB React before, using a single immutable app-state. However, we did the rendering like:
model = immutable({name:"X"});
function change_name(name){
swap(render(change("name", name, model))))
}
where render:
function render(state){
ReactDOM.render(<Todos app_state={state} />,document.getElementById('main'));
}
In reagent we use a r/atom, which on every swap will check whether we need to do another render. For very simple stuff, like the one above, that's ok, but if the operations are very complex, including a lot of back and forth ajax operations, controlling manually when the render should occur is better.
The TODOMVC of how we worked before is here: http://jsfiddle.net/danbunea1/bL62p47n/
As far as I know reagent batches changes with requestAnimationFrame
, and the components implement a smart shouldComponentUpdate
so I'd say that the defaults are very performance sensible and I'd suggest not prematurely optimizing.
That said, for accomplishing what you just asked, just perform the atom mutations after you've done all those expensive operations.
That way only when you swap!
, reset!
, etc at the end, will reagent consider triggering renders.