I have the following code and I think I am doing something fundamentally wrong.
(defn world-view [data owner opts]
(reify
om/IInitState
(init-state [_]
(om/update! data #(assoc % :world vec)))
om/IWillMount
(will-mount [_]
(go (let [world (<! (get-world (:dimensions opts)))]
(log (get-in world [9 9]))
(om/update! data #(assoc % :world world)))))
om/IRender
(render [this]
(log (get :world data))
(apply dom/table nil
(om/build-all row (:world data))))))
I am making a remote ajax call in om/IWillMount
like this:
om/IWillMount
(will-mount [_]
(go (let [world (<! (get-world (:dimensions opts)))]
(log (get-in world [9 9]))
(om/update! data #(assoc % :world world)))))
I am expecting a 2d vector back from the remote call and this works because I can log elements of the array with
(log (get-in world [9 9]))
I am then using om/update
to update the data structure.
But when render is called, the data does not appear to be updated, I can test this by trying to log the data structure
log (get :world data))
This logs nothing.
I can't see what I am doing wrong or why the data structure has not been updated.
om/update!
sets the cursor to the given value, so you're basically assigning a function to your cursor. I believe you should use om/transact!
instead.