So, using om-classic, I find myself writing:
(dom/td nil (inc (aget (aget owner "props") "__om_index")))
in a component which is built with om/build-all
RTFS’ing I see that om/build-all
does
(map (fn [x i]
(build f x (assoc m ::index i)))
xs (range))
there is also standard library function map-indexed
so you don’t have to use range
So I’d expect to find ::index
in the opts
map of my function, but the opts
map seems to be nil
What I’m after is a way to easily get a hold of the index of the thing I’m building in om/build-all
.
So, I guess what I’m looking for is (::index m)
being passed in opts
in
https://github.com/omcljs/om/blob/master/src/main/om/core.cljs#L975
so changing (let [ret (f cursor' this opts)] ...)
to (let [ret (f cursor' this (assoc opts ::index (::index m)))]...)