Support ES2015 Sets/iterables in ng-repeat #14600
Comments
As explained in #14123 this is not so much about |
How far do we want to take support for this for? What I mean by that is I was tinkering with supporting We could try to fall back to Opinions? |
We talked about it with @petebacondarwin a couple of weeks ago. We thought about using |
@gkalpak What's the gain of not supporting all iterable structures? |
@mgol, one problem is how to detect iterables (e.g. Another problem is that different iterables might need to be iterated over differently. E.g. for If anyone has suggestions on how to overcome these, that would be awesome, of course 😃 |
Couldn't one declare that if one wants to use iterables such as |
@wesleycho So the bigger challenge is that as @gkalpak was alluding to, the For example, There's also the question of supporting user generated iterables; do we require them to conform to a specific iterator contract for We could also choose to not follow the iteration protocol of using |
I think iterating over the result of calling |
I agree, I like the |
So I started tinkering with this and could use some input on a question related to You can already see behavior where we change an arrayLike item into a true array and pass that as the old value http://jsfiddle.net/rogqp47y/37/ The question is when it comes to iterables - what do we do? I feel like the expectation can't be that we maintain the behavior of the original collection ( Thoughts? |
Since there is already the precedent that we convert the passed in value to one of the supported object (i.e. we convert array-like objects to arrays), I think it is reasonable to do the same with iterables. If we decide to go with Another idea is to have an extra prerequisite, that iterables passed to var iter1 = /* some iterable */
var iter2 = new iter1.constructor(iter1); |
Is that a common thing? Like would that be following some specification for these kinds of collections? |
@gkalpak this would also be good to support Immutable.js objects. |
Here's a package that might work for those coming to this issue via google: https://www.npmjs.com/package/ng-next |
@gkalpak I like this idea; I think it’s a reasonable constraint / expectation. For example a subclass of re: |
Current available "work-around": |
Currently if I put an ES2015
Set
intong-repeat
I get no result (as the instance has no enumerable properties).I have to use
Array.from
to convertSet
s to arrays all the time. However, this call is not supported by Chrome until recently (even though theSet
API existed long ago).Theoretically this can be a generic implementation for (incl. Arrays), but I forsee issues with change detection, so I guess a Set-specific implementation might be suffice.
The text was updated successfully, but these errors were encountered: