Hi, everyone!

I have an Om problem, and I've looked all over the list archives and the 
documentation, but haven't been able to find an explanation. I *think* it's 
related to how cursors masquerade as/are constructed from vectors/maps, but 
perusing om/core didn't reveal anything immediately.

I've created a minimal test case to illustrate the problem. Basically, I have 
an indexed cursor being created from app-state with nil as the index "(get 
app-state nil)", which is then passed down. I would typically expect some sort 
of failure to render, but my particular code path happened to render ok, and I 
only found out the cursor was invalid after much-delayed weirdness with 
channels and transact!.

In one code path, it fails with an object identifier of some sort, but in 
another, it renders perfectly. If the items-view function calls build-all with 
item-view itself, rendering fails, but if items-view calls item-list-view, 
which then calls build-all with item-view, it succeeds!

The whole repo is at https://github.com/KingMob/om-cursor-test, but below is 
the relevant code. This was tested with Om 0.7.1 and cljs 2322.

Any help greatly appreciated,
Matthew

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Vector of item-groups
(def app-state 
  (atom [{
          :items [
                  {:text "Alice"}
                  {:text "Bob"}
                  {:text "Cindy"}
                  {:text "Dave"}
                  ]}
         {
          :items [
                  {:text "Eve"}
                  {:text "Fred"}
                  {:text "Gina"}
                  {:text "Howard"}
                  ]}]))

; Just makes a button with text
(defn item-view [item owner]
  (reify
    om/IRender
    (render [_]
            (dom/button nil
                        (:text item)))))


; Somehow, by going through this function, it displays correctly
(defn item-list-view [items owner]
  (reify
    om/IRender
    (render [_]
            (apply dom/div nil
                   (om/build-all item-view items)))))


(defn items-view [item-group owner]
  (reify
    om/IRender
    (render [_]
            (dom/div nil
                     
                     (dom/h3 nil "This one doesn't render a cursor involving 
nil. Instead we get some sort of OID.")
                     (om/build-all item-view (:items item-group)) ; seems like 
it should be identical to call in item-list-view

                     (dom/h3 nil "Yet this one renders with what seems like an 
identical code path!")
                     (om/build item-list-view (:items item-group))))))


(defn root-view [app-state owner]
  (reify
    om/IRender
    (render [_]
            (dom/div nil
                     (om/build items-view (get app-state nil)) ; here, we index 
into the vector of item-groups incorrectly, yet sometimes it renders
                     ))))

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