On Monday, January 13, 2014 9:12:58 AM UTC-6, David Nolen wrote: > On Sun, Jan 12, 2014 at 11:51 PM, Conrad Barski <[email protected]> wrote: > > > > Hi, I'm trying to store an array of data in Om state and instantiate a child > component with it by indexing into the array (by passing the derived cursor > into the child component.) > > > > > However, I don't get a cursor when I do this: > > > > (def x (om/to-cursor {:foo [1 2]})) > > > > (om/cursor? (:foo x)) ==> true > > > > (om/cursor? ((:foo x) 0)) ==> false > > > > Does anyone know why an array lookup doesn't yield a cursor in this case? Is > there something conceptually I'm missing? If this is how it's supposed to > work, how do I create an array of Om components out of an array of items in > the state? > > > > If you look at the Om source you'll see that only Maps and IIndexed have real > cursor conversions by default. Implementers of ICloneable can also be > converted into cursors. So if the following comes first your code will work: > > > > (extend-type number > ICloneable > (clone [n] (Number. n)) > > > However React does not render Number & String Objects properly as children, > so you will need the following: > > > > (dom/div nil (om/value n)) > > > If n is a number cursor. > > > David
Exactly what I needed to know to wrap my head around this- Thanks! -- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you are subscribed to the Google Groups "ClojureScript" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/clojurescript.
