Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOC] Add more guidance on using @each rather than [] #13198

Merged
merged 2 commits into from
Mar 30, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions packages/ember-runtime/lib/mixins/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,22 @@ 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. 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