Skip to content

Commit

Permalink
[DOC] Add more guidance on using @each rather than []
Browse files Browse the repository at this point in the history
Updated docs in response to
#12360

(cherry picked from commit f2b42ab)
  • Loading branch information
abepetrillo authored and rwjblue committed Apr 3, 2016
1 parent d93bf85 commit 78eaf04
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions packages/ember-runtime/lib/mixins/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,23 @@ export default Mixin.create(Enumerable, {
return an enumerable that maps automatically to the named key on the
member objects.
If you merely want to watch for any items being added or removed to the array,
use the `[]` property instead of `@each`.
@each should only be used in a non-terminal context, and is deprecated when
used as a leaf node. Example:
```javascript
myMethod: computed('[email protected]', function(){
...
});
```
If you merely want to watch for the array being changed, like an object being
replaced, added or removed, use `[]` instead of `@each`.
```javascript
myMethod: computed('posts.[]', function(){
...
});
```
@property @each
@public
Expand Down

0 comments on commit 78eaf04

Please sign in to comment.