DDAU: readonly attributes still modifiable, just not reassignable


#1

I’m just thinking about guidance to give beginners for implementing DDAU with the current release version of Ember that obviously doesn’t enforce readonly attribute assignments for components and am actually not sure whether I’m missing sth. or whether this is actually sth. that doesn’t currently work as it should.

When attributes are assigned using the readonly helper which as far as I’m aware of is the way to go to enforce DDAU currently those attributes aren’t directly reassignable but any properties of them might still be modifiable which I think would violate DDAU. A simp,e example would be, e.g.

{{settings-pane user=(readonly user) on-change=(action 'updateUser')}}

of course the user attribute of the outer context would not be reassignable from the settings-pane component but any of the user’s properties could still be modified which would not actually be DDAU.

Again, I’m not sure I’m just missing sth. here. Also, one could of course assign all the user’s attributes that the component needs as separat attributes of the component but I’m not sure an example like this where an object is assigned to a component attribute is invalid per se. I’m thinking that the readonly would actually have to return a frozen instance of the object that would also not allow any modifications?


#2

I don’t know is this is related to a pojo bug I ran into but I fixed that with use-get-and-set .


#3

That’s not related actually. I’m also not sure I agree with it - get(this, 'whatever') is never necessary actually, get(object, 'whatever') might be


#4

Thanks! I read:

The readonly helper wraps the property in a way that disables set on the property, this forces the property to be set using an action. This way if you are using a component that still supports setting in the old way your properties won’t be unexpectedly updated.

Source : http://emberup.co/bindings-with-htmlbars-helpers/

Is this a copy off the official definition? I don’t see it here: http://emberjs.com/api/classes/Ember.Templates.helpers.html