There are few things that I consider for the forEach directive:
- Assume the forEach will not built only for arrays but for any iterable(Map, Set, generator) if then it's might be good to consider less verbose approach (with many attributes like
index,key,item)
- The item={item} is something different from other directives because it's defining a scoped variable and not using one.
- Access the index of the iteration might also be important (not printing the last divider)
- Not sure about async iterations but it can be also supported
Maybe embrace the JS syntax for of that when the left side if the of is always a const it's. with some sugar for the index.
<div for="items" trackBy={expr}></div> - cool auto destructure
<div for="item of items" trackBy={expr}></div>
<div for="[key, value] of items" trackBy={expr}></div>
<div for="[index, value] of items" trackBy={expr}></div>
<div for="[key, value, index] of items" trackBy={expr}></div> - index sugar
Async
<div for="await value of promises" trackBy={expr}></div>
Or
<div for-await="value of promises" trackBy={expr}></div>
There are few things that I consider for the
forEachdirective:index,key,item)Maybe embrace the JS syntax
for ofthat when the left side if theofis always a const it's. with some sugar for the index.<div for="items" trackBy={expr}></div>- cool auto destructure<div for="item of items" trackBy={expr}></div><div for="[key, value] of items" trackBy={expr}></div><div for="[index, value] of items" trackBy={expr}></div><div for="[key, value, index] of items" trackBy={expr}></div>- index sugarAsync
<div for="await value of promises" trackBy={expr}></div>Or
<div for-await="value of promises" trackBy={expr}></div>