(defn app-state
(atom {:attributes {... map of an id to info about that id ...}
:id-sequence [id1 id5 id4 id7... etc as if based on a sorting order or other sequence, perhaps even repeated items]}))
Now suppose I want to call build-all on :id-sequence but then use info from :attributes after getting an item from the vector?
One bloated option would be to create a new sequence in the app state that holds the id and its attributes, which would mean for repeated ids the same attributes are stored multiple times.
Unlike other Om components, I'm guessing build-all is not designed to accept multiple cursors since it needs a single sequence to do its thing.
Can anyone advise a good approach?
(def app-state
(atom
(:attrs {1 "one" 2 "two" 3 "three" 4 "four"}
:ids [1 2 3 3 4 2]}))
(defn number-view [[id attrs] _]
(reify
(om/IRender
(render [this] (dom/li nil (get attrs id)))))
(cursor-tuples [state]
(map vector (:ids state) (repeat (:attrs state))))
(defn numbers-view [app _]
(reify
om/IRender
(render [this]
(dom/div nil
(apply (dom/ul nil
(om/build-all number-view (cursor-tuples app)))))))
Apologies for any typos, typing from a mobile device.
He maps over an id-sequence just like would want. Let me know if you have any follow up questions.