ember-group-by
ember-group-by copied to clipboard
[ENHANCEMENT] Added optional comparator property to handle complex value
Ember findBy
method compare by identity and that's good for primitive values, but when we deal with objects identity could not be the perfect solution.
For example, 2 different Date
objects referring both to today are !==
, however are equals conceptually.
To handle this I've added a comparator property that works like this
import Ember from 'ember';
import groupBy from 'ember-group-by';
export default Ember.Controller.extend({
modelByDate: groupBy('model', 'date', function(previousDate, currentDate) {
return previousDate.getTime() === currentDate.getTime();
})
});
Hope this gets merged, cause I think there're many use case where this could be useful. P.S. I've also updated the ember-cli version and added test
@Fed03 you're probably not interested anymore, but this is a great idea. If, by any change, you're still interested, you could rebase this PR and I could merge it in.