Ok, thanks. Going back and re-reading the doc, it makes sense to me now. 

On Tuesday, September 2, 2014 5:07:24 PM UTC-4, David Nolen wrote:
> The documentation explicitly states what types of values are supported
> 
> out of box wrt converting into cursors - IMap & IIndexed only. List is
> 
> not IIndexed. If you want List to work you need to implement IToCursor
> 
> for this type.
> 
> 
> 
> David
> 
> 
> 
> On Tue, Sep 2, 2014 at 5:00 PM, Steve Ashton wrote:
> 
> > Here's some sample code that demonstrates the difference. Things work if 
> > the app-state atom is built from a vector. It fails if it is built from a 
> > list.
> 
> >
> 
> >
> 
> >
> 
> > (ns om-tut.core
> 
> >   (:require [om.core :as om :include-macros true]
> 
> >             [om.dom :as dom :include-macros true]))
> 
> >
> 
> > (enable-console-print!)
> 
> >
> 
> >
> 
> > ;; Swap the following two lines to see the difference. It works with the 
> > vector,
> 
> > ;; but throws an error with the list.
> 
> > (def app-state (atom {:list (list {:num 1}{:num 2}{:num 3})}))
> 
> > ;; (def app-state (atom {:list (vector {:num 1}{:num 2}{:num 3})}))
> 
> >
> 
> > (defn my-component [state owner]
> 
> >   (reify
> 
> >     om/IWillMount
> 
> >     (will-mount [_]
> 
> >       (println "I see the cursor type as: " (type state)))
> 
> >     om/IRender
> 
> >     (render [_]
> 
> >       (dom/div nil (:num state)
> 
> >                (dom/button #js {:onClick (fn [e] (println "You clicked " 
> > @state))} "Print")))))
> 
> >
> 
> > (om/root
> 
> >   (fn [app owner]
> 
> >     (reify om/IRender
> 
> >       (render [_]
> 
> >         (dom/div nil
> 
> >                  (apply dom/div nil
> 
> >                         (om/build-all my-component (:list app)))))))
> 
> >   app-state
> 
> >   {:target (. js/document (getElementById "app"))})
> 
> >
> 
> >
> 
> >
> 
> > On Tuesday, September 2, 2014 1:29:43 PM UTC-4, Steve Ashton wrote:
> 
> >> It appears to me that lists are not a supported collection to be used as a 
> >> cursor. I see in the cursor doc it does specifically mention vectors and 
> >> maps, but not lists:
> 
> >>
> 
> >>     "During the render phase, you treat a cursor as a value, as a regular 
> >> map or vector."
> 
> >>
> 
> >> I'm not sure if that means lists aren't supported, or that lists are 
> >> converted to vectors internal to the cursor. If it is the former, what is 
> >> the reason? If it is the latter, I have found some inconsistent behavior 
> >> between vectors and lists in cursors.
> 
> >>
> 
> >> My use case for using a list is putting an edn formatted response into a 
> >> cursor. If I use the data as I get it, it is a list.
> 
> >
> 



-- 
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.

Reply via email to