-
-
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 []
Updated docs in response to #12360
- Loading branch information
1 parent
e35e8b4
commit f2b42ab
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 |
---|---|---|
|
@@ -540,8 +540,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 | ||
|