Troubles with om's `update!` in regards to `transact!`

107 views
Skip to first unread message

David Mohl

unread,
Nov 28, 2014, 4:28:25 AM11/28/14
to clojur...@googlegroups.com
Hey there. I am constantly running into a small issue with om/update! and om/transact! and look for a point into the right direction.

This snippet sets the `some-value` state to true.

(om/transact! app [:some-value] (fn [_] true))

The way I understood it from the documentation (https://github.com/swannodette/om/wiki/Documentation#update), I should be able to accomplish the same thing by using the following update statement:

(om/update! app [:some-value] true)

While the `transact!` one works fine, `update!` is always throwing `Uncaught TypeError: Cannot read property 'closure_uid_xxxxxxx' of null`

I am wondering what I'm doing wrong or where my thinking error is.

Ahmad Hammad

unread,
Nov 28, 2014, 9:29:47 AM11/28/14
to clojur...@googlegroups.com
update! is simply calling transact! for you just the way you called it initially so i don't see how it could be the problem, here is the source:

(defn update!
"Like transact! but no function provided, instead a replacement
value is given."
([cursor v]
(transact! cursor [] (fn [_] v) nil))
([cursor korks v]
(transact! cursor korks (fn [_] v) nil))
([cursor korks v tag]
(transact! cursor korks (fn [_] v) tag)))

jack james

unread,
Nov 28, 2014, 9:37:26 AM11/28/14
to clojur...@googlegroups.com
i can't reproduce this. can you post a minimal case showing an example where transact! succeeds and update! fails?

https://www.refheap.com/94143

David Mohl

unread,
Nov 28, 2014, 12:15:00 PM11/28/14
to clojur...@googlegroups.com
Hey Jack,

here are 2 specific examples taken from my codebase. One inside a render, one inside a will-mount: https://www.refheap.com/fec9b8d2d50ce755214817b21

In both cases, if I use update! instead of transact!, it fails. The update! line would be something like (om/update! app [:data] data)

In both cases, transact! is inside a go black. Can this be related to the issue? 
The ajax functions return simple clojure maps. Using static values or bools results in the same issue.

I also updated to the latest om to see if this is related, but the issue still persists. 

--
Note that posts from new members are moderated - please be patient with your first post.
---
You received this message because you are subscribed to a topic in the Google Groups "ClojureScript" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojurescript/IsFBzjXDNhw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojurescrip...@googlegroups.com.
To post to this group, send email to clojur...@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.

jack james

unread,
Dec 13, 2014, 9:51:21 AM12/13/14
to clojur...@googlegroups.com
Apologies for being slow on this. Unfortunately, I'm still unable reproduce the issue. This runs without error: https://www.refheap.com/94842

What we need is a complete (minimal) case that demonstrates the issue. The above refheap is an example in that it is a complete Om application: you can easily do "lein new mies-om update-test", copy/paste from the refheap overwriting the contents of core.cljs, and run the app. The examples you provided might be sufficient in many cases, but i'm not able to reproduce this issue from them.

David Nolen

unread,
Dec 13, 2014, 10:12:08 AM12/13/14
to clojur...@googlegroups.com
FWIW this kind of error looks like something that might crop if you
have a bad build. Have you run a `lein cljsbuild clean` in some time?
What are your project build settings?

David
> --
> 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 clojurescrip...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages