Skip to content

forEach directive #4

Description

@barak007

There are few things that I consider for the forEach directive:

  1. 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)
  2. The item={item} is something different from other directives because it's defining a scoped variable and not using one.
  3. Access the index of the iteration might also be important (not printing the last divider)
  4. 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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions