Hi Timothy We ran into a similar issue recently as well, see http://dev.clojure.org/jira/browse/ASYNC-137 for more details. I *think* in your case you would need to split your work up into chunks and yield control back to the browser after each chunk of work (with a (timeout 0)). See https://github.com/Day8/re-frame/wiki/Solve-the-CPU-hog-problem for more details on this approach.
On Tue, Aug 25, 2015 at 3:33 AM Timothy Pratley <timothyprat...@gmail.com> wrote: > I have an issue where work inside a 'go block' is blocking my UI. > Inserting a (<! (timeout 1)) 'fixes' it. > > ** Is there a more idiomatic way? ** > > Here is a cut down version built from a fresh template: > If you run this code, you don't see the thinking deeply countdown, and you > cannot click the other button. > > If you uncomment the timeout 1, it works better. > > > > (defn hello-world [] > [:div > [:h1 (:text @app-state)] > [:button > {:on-click > (fn [e] > (swap! app-state assoc :thinking true :thinking-deeply 5) > (go > (while (pos? (:thinking-deeply @app-state)) > ;(<! (timeout 2000)) > (apply * (rest (range 10000000))) > ;(<! (timeout 1)) > (swap! app-state update :thinking-deeply dec)) > (swap! app-state dissoc :thinking :thinking-deeply)))} > "The button!"] > (when (:thinking-deeply @app-state) > [:h2 "Thinking deeply " (:thinking-deeply @app-state)]) > (when (:thinking @app-state) > [:h2 "Thinking"]) > [:button "The other button"]]) > > Full source code is attached > > > Regards, > Timothy > > -- > 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. > -- -- Daniel -- 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.