I'd like to see more enumerable functions, min/max
and groupBy
are just a few I've recently used, but there are many more (Ruby's Enumerable is what I am thinking of). While these functions are easy to implement, it would be nice to see them in Ember. I know that Ember.Enumerable wants to stay as close as possible to the JS API, so it sounds like that is not a good place for these.
There are a lot of 3rd party libs that build out these functions for you. However, because of Ember's use of proxies (like DS.ManyArray) you have to remember to call toArray
on the relationship. This creates ugly code: groupBy(person.get('posts').toArray(), 'category')
. What's worse is these 3rd party libs don't know about Ember's binding system, so the above turns into groupBy(person.get('posts').toArray(), function(post) { return post.get('category') });
. I think it's a lot easier to think of the above as person.get('posts').groupBy('category')
.
Is there interest for these functions? If so, how should they be implemented. ArrayProxy mixin(s)?