Flattening an Array


#1

I would like to propose that a utility in Ember.ArrayProxy be created to flatten nested arrays.

Similar to this gist by Mehul Kar, I’ve run into many situations that require multi-level relationships to be flattened in order to provide a better user experience. By implementing the flatten utility into the Ember library we can help eliminate custom solutions and confusion when it comes to working with Array’s, including PromiseArray and ManyArray in Ember Data.

Thoughts? Opinions?


#2

This might be better done as a computed property. We can create a collection of computed properties that can be reused. If some become popular, then we can propose them to go into the core.

Would this work for you?


#3

This was brought forward as a PR a few months back but rejected into core for being a little too specific.


#4

@tarasm Sounds like a good idea. Although I’m not familiar with using the computed properties to accomplish this. Is there more documentation on Ember.Computed?


#5

You’re probably better off using this guys computed rather than reinventing the wheel. https://github.com/emberjs/ember.js/pull/3503/files