Style when writing components that might be mutable


When I’m writing a component, it is up to the user of the component whether they wrap an attribute in the mut helper. It would seem that, if I want to support non-immutable components, I need to check if the component is wrapped in mut.

Is this correct? And if so, what is the best way to check for mut? Just || doesn’t seem very robust.

The new paradigm seems a bit strange to me – that the user not the component author decides what is mutable and what is not. If someone could comment on why its designed this way I’d be grateful.

(I guess the answer is partly because “data-down” means its up to the invoker to decide whether to accept anything coming back up. But it seems odd that the “internal interface” inside the component isn’t more robust. Just because I’m not allowed to push data back up doesn’t mean I can’t be allowed not to accept data coming back down, or that I should even care whether or not data is actually being propagated back up.)


In the internals there is a helper for this (see

import Ember from 'ember'; var getMutValue =

Perhaps this could be promoted to the public API: (<component>.getAttrValue(key) ?).

As for the overall interface, I would have preferred all attributes automatically wrapped in “mut” – but if the invoker didn’t use a mut helper the update function would simply update the component’s own attribute without transmitting it to the parent.


I would version my component accordingly for 2.0 and drop support for mutating the attributes directly instead would solely rely on actions.