Skip to content

Commit

Permalink
[DOC relase] Improve mut documentation
Browse files Browse the repository at this point in the history
`mut` documentation contains code that does not work. It also references a blog
post with outdated information.

This PR fixes the code with the right behaviour and remove the link to avoid
confussion.

Fixes emberjs#14057
  • Loading branch information
Serabe committed Aug 14, 2016
1 parent 31d3ba7 commit 436c330
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions packages/ember-glimmer/lib/helpers/mut.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,20 @@ import { INVOKE } from './action';
The `mut` helper lets you __clearly specify__ that a child `Component` can update the
(mutable) value passed to it, which will __change the value of the parent component__.
This is very helpful for passing mutable values to a `Component` of any size, but
critical to understanding the logic of a large/complex `Component`.
To specify that a parameter is mutable, when invoking the child `Component`:
```handlebars
{{my-child childClickCount=(mut totalClicks)}}
```
The child `Component` can then modify the parent's value as needed:
The child `Component` can then modify the parent's value just by modifying its own
property:
```javascript
// my-child.js
export default Component.extend({
click() {
this.get('childClickCount').update(this.get('childClickCount').value + 1);
this.incrementProperty('childClickCount');
}
});
```
Expand All @@ -47,9 +45,6 @@ import { INVOKE } from './action';
The `mut` helper changes the `totalClicks` value to what was provided as the action argument.
See a [2.0 blog post](http://emberjs.com/blog/2015/05/10/run-up-to-two-oh.html#toc_the-code-mut-code-helper) for
additional information on using `{{mut}}`.
@method mut
@param {Object} [attr] the "two-way" attribute that can be modified.
@for Ember.Templates.helpers
Expand Down

0 comments on commit 436c330

Please sign in to comment.