Ember.computed.instance

as explained here : https://github.com/emberjs/ember.js/issues/4134 I wonder if this feature would be good or not, what do you think ?

3 Likes

I like the idea. I think it lets you have more elegant code vs. needing to implement init

@lukemelia this is the purpose :), but also it avoids errors on common mistakes with object reference

I really like the idea here…but putting it as part of Ember.computed seems a little confusing. (It’s really not depending on another property which is what the whole computed library is about).

What if it were something like this instead?

Ember.Object.extend({
  prop: [].instance(),
  prop2: Em.Object.extend().instance()
});

That could give you some extra flexibility…the array, for example, could be repopulated with some default values:

Em.Object.extend({
  prop : [1,2,3,4].instance()
});

huum, I like your idea, the result is the same, but in my philosophy, a computed property is just a dynamic property depending or not on other properties, objects …, i this case it depends on the type of object to initialize. just one question:

[].instance() // would export a computed property?

personally, i prefer the best way to achieve the goal!

1 Like

any suggestions before I start implementing ? should i ?

@wycats @lukemelia @Spencer_Price