Hi, I have found a bug, but it may well be (almost certainly is) in my understanding ;).
tldr; I decorate something from app-state and store as component-state. In rendering I see the decorated thing but in on-click when I resolve the cursor I see the undecorated thing. I have a hierarchy in my app-state and a tree-component to render it. The tree component denormalises the tree so each node has an array of its parent's ids and descendant ids (for example). I then persist this decorated-tree as component state. The problem is that when I reference the decorated tree in the on-click, I can see the cursor has access to the decorated tree but when I denormalise it I see the undecorated tree. (As an aside, I originally tried it without component state and passed the decorated tree as app-state to the delegate component but that exhibited the same behaviour). I am sure I have missed something, but I don't see what - is this a bug in om? I can by-pass this by simply storing everything in app-state in the denormalised view, but that is not ideal - different components want to render the same domain chunk differently (e.g. another component might show this tree as a flattened list). The following code demonstrates the behaviour: [code] (defn the-component [_ owner] (reify om/IDisplayName (display-name [_] "Component") om/IRenderState (render-state [_ {:keys [node]}] (let [{:keys [id text children meta]} node] (js/console.log "NODE in rendering contains meta:" (clj->js (keys node))) (html [:li {:key id :on-click (fn [e] ;; prevent selection of the parent (. e stopPropagation) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; the cursor node contains the "meta" key if you expand ;; into .value.root.arr[2] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (js/console.log "(cursor)NODE in on-click (check .value.root.arr[2]):") (js/console.log node) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; however it has all gone pear shape here... ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (js/console.log "(deref)NODE in on-click no longer has 'meta':" (clj->js (keys @node))))} "Click me"]))))) (defn tree [{:keys [node] :as data} owner] (reify om/IDisplayName (display-name [_] "Tree") om/IInitState (init-state [_] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; decorate the value of the cursor from app-state ;; but store locally ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; {:node (assoc node :meta {})}) om/IRenderState (render-state [_ {:keys [node]}] (om/build the-component nil {:init-state {:node node}})))) [/code] (any and all comments welcome!) 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 clojurescript+unsubscr...@googlegroups.com. To post to this group, send email to clojurescript@googlegroups.com. Visit this group at http://groups.google.com/group/clojurescript.