5 ms·
You can very easily do this by combining Object.observe() (or a polyfill) and calling forceUpdate(). However we've found that this sort of data binding is subo
by peterhunt 13y ago
You can very easily do this by combining Object.observe() (or a polyfill) and calling forceUpdate().
However we've found that this sort of data binding is suboptimal since it encourages mutation which forces you out of some great perf optimizations (like the Om stuff, and Object.observe() has its own performance penalties). And thinking about your data flow a little more explicitly makes it easy to follow where updates are being triggered from (so a mutation in one part of your app doesn't accidentally trigger updates all over the place).
Most of the time doing this explicitly is a little more typing up front but is worth it for larger apps from a performance and maintenance perspective. If you start building with React you'll find that your data model flattens out as you go down the view hierarchy so this becomes less of an issue.
- juliangamble 13y agoYou can read more about how React combined with immutable data structures provides great performance in this blog post by David Nolen http://swannodette.github.io/2013/12/17/the-future-of-javascript-mvcs/ http://swannodette.github.io/2013/12/17/the-future-of-javasc...