How do I extend Ember.ArrayProxy? I have tried the following:
Ember.ArrayProxy.reopenClass({
flatten: function(){
var r = [];
this.forEach(function(el) {
r.push.apply(r, Ember.isArray(el) ? el.flatten() : [el]);
});
return r;
}
});
But ended up writing the following solution:
// Source: https://gist.github.com/mehulkar/3232255
Array.prototype.flatten = Ember.ArrayProxy.prototype.flatten =function() {
var r = [];
this.forEach(function(el) {
r.push.apply(r, Ember.isArray(el) ? el.flatten() : [el]);
});
return r;
};
Is there something I'm missing in the former example? I'm trying to stick with Ember's methodology, so I would prefer not to use the later.