Skip to content

Adding index as a parameter to f when using build-all #890

Open
@slipset

Description

@slipset

Problem statement:

I have a list of items that I want to output in a table. Before each item, I want to output the rank of the item:

| 1 | First item       |
| 2 | Second item |

To do this I use code along these lines:

(om/build-all display-row rows  {:key :id})

Looking at the source-code,
I see that build-all uses map with an index (why not map-indexed?),
but that index (::index) is lost on the way down to my display-row function.

The only way I've managed to get a hold of the index is by the way of the following code:

(aget (aget owner "props") "__om_index")

which seems a bit hackish to me.

Proposed solution:
Add a :index keyword to the opts map for a component which contains the current index if the component is built using build-all

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions