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

Array helpers don't notify length change #1573

Closed
mbleigh opened this issue May 20, 2015 · 4 comments
Closed

Array helpers don't notify length change #1573

mbleigh opened this issue May 20, 2015 · 4 comments
Assignees

Comments

@mbleigh
Copy link

mbleigh commented May 20, 2015

If I use the built-in array mutation helpers, I would expect that they would properly notify not just on the array itself but also on its length. Right now I have an app with a counter and I have to manually notifyPath for the length each time I mutate the array.

@kevinpschaaf
Copy link
Member

You can observe array.splices or array.*, which will get notified for any array mutations that affect the length of the array. Is that sufficient?

@mbleigh
Copy link
Author

mbleigh commented May 20, 2015

It works in terms of giving me a workaround without manual notification but
will then require me to memoize the length in a separate value instead of
being able to bind to it directly. Not the end of the world, but "counter
for an array property" is likely a common use case and I wouldn't be
surprised if other people run into the same issue.

On Wed, May 20, 2015 at 10:05 AM Kevin Schaaf [email protected]
wrote:

You can observe array.splices or array.*, which will get notified for any
array mutations that affect the length of the array. Is that sufficient?


Reply to this email directly or view it on GitHub
#1573 (comment).

@kevinpschaaf
Copy link
Member

I see, you'd like to bind the actual length length into the template, got it.

Sort-term, you could also do this, to avoid needed to make a property:

{{arrayLength(array.*)}}

arrayLength: function(change) {
   return change.base.length;
}

@kevinpschaaf kevinpschaaf assigned kevmoo and kevinpschaaf and unassigned kevmoo May 21, 2015
@kevinpschaaf kevinpschaaf added p2 and removed p3 labels May 21, 2015
sorvell pushed a commit that referenced this issue May 23, 2015
Notify array.length changes.  Fixes #1573.
@mbleigh
Copy link
Author

mbleigh commented May 23, 2015

Nice!

On Fri, May 22, 2015, 8:27 PM Kevin Schaaf [email protected] wrote:

Closed #1573 #1573 via 0a06a72
0a06a72
.


Reply to this email directly or view it on GitHub
#1573 (comment).

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

3 participants