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

Is 'array.@each' correct? #2016

Closed
joliss opened this issue Feb 8, 2013 · 5 comments
Closed

Is 'array.@each' correct? #2016

joliss opened this issue Feb 8, 2013 · 5 comments
Assignees
Milestone

Comments

@joliss
Copy link
Contributor

joliss commented Feb 8, 2013

I sometimes see people write (function() { ... }).property('array.@each'). Is that actually a correct way to bind to each element of the array?

Either way, we should clarify that on http://emberjs.com/guides/object-model/computed-properties-and-aggregate-data/ and perhaps http://emberjs.com/api/classes/Ember.MutableArray.html#property__each.

@wagenet
Copy link
Member

wagenet commented Feb 8, 2013

@joliss that works fine, though it's slightly more efficient to do array.[].

@bradleypriest
Copy link
Member

Similar thought, array.length would be sufficient for a lot of cases, wouldn't it, I assume it's more performant, should we mention that as well?

@krisselden
Copy link
Contributor

observing array.length and array.[] are the same performance wise, they are both notified during .replace() which is what all mutations to an Ember.MutableArray go through. array.@each creates an EachProxy which installs observers, it is more for observing properties of the objects in an array.

@ghost ghost assigned trek Mar 4, 2013
@endash
Copy link
Contributor

endash commented Mar 4, 2013

length is only notified though if the length ACTUALLY changes. Swapping out an element for instance would NOT notify length, while it WOULD notify [].

edit: 24 days ago... I have no idea why this showed up at the top of the list. very strange.

@wagenet
Copy link
Member

wagenet commented Aug 24, 2013

I still see people making this error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants