3 ms·
How do you know what things depend on X? if you have Z=Y+X, do you also refresh Z? State control is not simple when you have many moving parts. A very good sol
by rtpg 11y ago
How do you know what things depend on X? if you have Z=Y+X, do you also refresh Z?
State control is not simple when you have many moving parts. A very good solution (which both Angular and React bring to the table without destroying performance most of the time) is to remove all the moving aspects to the parts. This doesn't matter in microbenchmarks, but in real apps, having something be slightly slower but bug-free is better than fast but wrong.
- kenOfYugen 11y agoI like Douglas Crockford's "Class Free OOP" approach for managing dependencies and composing functions: function constructor(spec) { let {member} = spec, {other} = other_constructor(spec), method = function () { // accesses member, other, method, spec }; return Object.freeze({ method, other }); } but prefer to use an immutable data structure instead of Object.freeze(). All application state can be stored in a single "Atom" (i.e immutable data) and all message passing can be achieved through CSP channels. When dealing with the DOM, 'incremental-dom' is a nice option. Of course, separating pure functions from side-effects inducing code is key to maintaining control. This is my approach when going "framework-less".