component / model

Minimalistic extensible data models
122 stars 40 forks source link

computed properties #14

Closed tj closed 11 years ago

tj commented 11 years ago

add a method to define a method or property as computed, for example if .fullname were computed, when either .first or .last is updated then emit change fullname as well as change first / change last

weepy commented 11 years ago

would this work like Ember ?

tj commented 11 years ago

I dont know what ember does, but it would work like I describe haha. Hopefully in a much less ugly way than ember

weepy commented 11 years ago

Sorry I meant as in you would specify the dependencies. I think Ember does something like property.dependencies(firstName, secondName).

tj commented 11 years ago

yeah you'll have to define it explicitly in some way, I haven't decided on a method name yet

weepy commented 11 years ago

I've got an implementation of something similar at: https://github.com/weepy/attr

ianstormtaylor commented 11 years ago

curious, does this belong on model? i would have assumed this was the view's responsibility, but am probably just not thinking of a useful case

esundahl commented 11 years ago

Seems to me it would be better to keep logic out of the view.

esundahl commented 11 years ago

@ianstormtaylor I think I realize now what you were referring to. I just noticed that reactive accepts an optional view parameter for overriding properties. Maybe this is obsolete.

tj commented 11 years ago

@ianstormtaylor yeah tough call, I like that this would keep the "ugly" in js-land, but I dislike introducing weird ways to define methods that otherwise would just be regular method. Ember's hack on the function prototype is even worse. We need the support at the view level anyway so I think maybe something like reactive(el).computed('fullname', 'first last') would be a decent compromise

tj commented 11 years ago

closing for now