-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DOC] Add more guidance on using @each rather than []
- Loading branch information
1 parent
d93bf85
commit 78eaf04
Showing
1 changed file
with
17 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|