I get quite a bit of data pushed onto these channels, sometimes a thousand puts per seconds on each. I can run my app fine for many minutes with considerable updates and there is no problem: the channels and Om respond as advertised.
Eventually, however, everything stops with the console message:
Uncaught Error: Assert failed: No more than 1024 pending puts are allowed on a single channel.
(I also found a similar unanswered SO question here: http://stackoverflow.com/questions/24753884/no-more-than-1024-pending-put-on-a-single-channel)
I am aware of what this message means but not sure what would cause it unless the infinite go loop in IWillMount stops doing its thing. Now, I came across this:
https://twitter.com/swannodette/status/456131778781396992
Noteable info from that exchange: "run into issues if there are pending puts when initiate the go block...[no] problem if start with channel reads [first]."
I can expect I might have puts onto a channel before Om first starts reading them, so should I consider doing something more than a mere go loop in IWillMount? I have something like this now:
(defn watch-root
"The invisible parent root that monitors all state changes from core.async channels and then builds the actual interface in main-root."
[app owner]
(reify
om/IWillMount
(will-mount [this]
(go (while true
(let [t (<! state/chan-om-transact)]
#_(println t)
(apply om/transact! app t))))
(go (while true
(let [u (<! state/chan-om-update)]
#_(println u)
(apply om/update! app u)))))
om/IRender
(render [this]
(om/build main-root app))))
A "slow consumer" is a common problem in a messaging situation and core.async has 2 built-in ways to deal with that. You can either use (async/chan (async/slliding-buffer n)) or (async/dropping-buffer n), both will start dropping messages either at the head or tail of the buffer. Contrary to popular believe React is actually quite slow when doing alot of state updates, it just doesn't appear that way since all updates are batched together in a "frame".
If you can't afford to drop messages you could try using a WebWorker to do processing in another thread and push state updates seperately.
But, as I said, not an Om user, just an educated guess.
Cheers,
/thomas
It looks like you might be putting things on a channel within the IRender lifecycle hook which will happen once each time there is a state change.
Will
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.