On Saturday, April 4, 2015 at 7:10:00 AM UTC+3, Mike Thompson wrote:
> So the problem sequence would be:
>    1.  first event handler called with db snapshot
>    2.  sync-dispatch called, making changes to app-db 
>    3.  first event handler finishes, and the value it returns is written into 
> app-db 
> 
> The changes in step 2 are lost.

I tried to replicate this but with no luck:
(register-handler
  ::input-change
  (fn [db [_ value]]
    (println "input changed to" value)
    (assoc db :my-value value)))
(register-handler
  ::badtimes
  (fn [db _]
    (let [my-future (+ (.getTime (js/Date.)) 3000)]
      (println "badtimes START")
      (loop []
        (if (< (.getTime (js/Date.)) my-future)
          (recur)))
        (println "badtimes END")
        (assoc db :badtimes my-future))))

::badtimes called with dispatch, ::input-change called with dispatch-sync while 
badtimes running i get:

badtimes START
badtimes END
input change to a
input change to ab
input change to abc... etc

Since handler functions are always synchronous could the warnings on 
dispatch-sync be a non-issue? Dispatch-synced events get in front of the line 
but they still have to wait for the current handler call to end. So there 
should be no problems as everyone gets the new db snapshot. Unless i'm missing 
something huge

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to