# Style when writing components that might be mutable

**URL:** <https://discuss.emberjs.com/t/style-when-writing-components-that-might-be-mutable/8563>\
**Category:** Uncategorized\
**Created:** [August 13, 2015, 2:38am UTC](https://discuss.emberjs.com/t/style-when-writing-components-that-might-be-mutable/8563 "2015-08-13T02:38:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaunc](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/shaunc/32/5422_2.png) [@shaunc](https://discuss.emberjs.com/u/shaunc)\
**Post date:** [August 13, 2015, 2:38am UTC](https://discuss.emberjs.com/t/style-when-writing-components-that-might-be-mutable/8563/1 "2015-08-13T02:38:20Z")

</div>

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 `attr.foo.value || attr.foo` 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.)

---

<div class="post-metadata">

**Author:** ![shaunc](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/shaunc/32/5422_2.png) [@shaunc](https://discuss.emberjs.com/u/shaunc)\
**Post date:** [August 13, 2015, 3:17pm UTC](https://discuss.emberjs.com/t/style-when-writing-components-that-might-be-mutable/8563/2 "2015-08-13T15:17:56Z")

</div>

In the internals there is a helper for this (see [ember.js - How to check for the presence of attribute wrapped in "mut" helper? - Stack Overflow](http://stackoverflow.com/questions/31978743/how-to-check-for-the-presence-of-attribute-wrapped-in-mut-helper))

```
import Ember from 'ember'; var getMutValue =
Ember.__loader.require('ember-htmlbars/hooks/get-value')['default'];

```

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.

---

<div class="post-metadata">

**Author:** ![jasonmit](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/jasonmit/32/182_2.png) [@jasonmit](https://discuss.emberjs.com/u/jasonmit)\
**Post date:** [August 13, 2015, 5:54pm UTC](https://discuss.emberjs.com/t/style-when-writing-components-that-might-be-mutable/8563/3 "2015-08-13T17:54:10Z")

</div>

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