@drogus wrote:
Recently I've read a lot about a new observable library written initially for ReactJS. From what I see on the surface it doesn't differ from what Ember.js offers a lot apart from one thing - properties don't need dependencies. For me this is a huge deal, because dependencies on properties are one of the worst parts of Ember.js in my opinion. A few reasons on top of my head:
- they may be hard to understand for beginners (I've seen confusion on this several times)
- a typo in a dependency may cause bugs that are hard to find, it will usually break only when a value changes after the initial page load
- dependencies are just boilerplate
- depending on nested collections is not possible without workarounds at the moment
As far as I understand how MobX works, dependencies are calculated on runtime - when a property is calculated, each lookup is registered and added to dependencies. This is neat and I think it may be actually faster than specifying dependencies by hand. Let's consider a following property:
Ember.computed('useFoo', 'foo', function() { if(this.get('useFoo')) { return this.get('foo'); } else { return this.complicatedAndSlowComputation(); } });
Currently in Ember.js, when
foo
changes, the property will be recomputed even ifuseFoo
is set tofalse
. If Ember.js worked more like MobX anduseFoo
was set tofalse
, onlyuseFoo
property would be registered as a dependency (becausefoo
wouldn't be reached).I'm wondering if a similar model could be introduced to Ember.js? My limited knowledge of Ember's observable code tells me that it could be possible, but I'm not really sure about that.
Posts: 1
Participants: 1