                          (do
                            (deliver prom true)
                            :done))))
-    (action-fn)
-    (snd "/sync" id)
-    (await-promise! prom)))
+    (let [res (action-fn)]
+      (snd "/sync" id)
+      (await-promise! prom)
+      res)))
 
 
 (defn stop


(defn on-server-sync
  "Registers the handler to be executed when all the osc messages generated
   by executing the action-fn have completed."
  [action-fn handler-fn]
  (let [id (update-server-sync-id)]
    (on-event "/synced" (uuid)

                         (do
                           (handler-fn)
                           :done))))

    (let [res (action-fn)]
      (snd "/sync" id)
      res)))

(defn with-server-sync
  "Blocks current thread until all osc messages in action-fn have completed.
  Returns result of action-fn."
  [action-fn]
  (let [id (update-server-sync-id)
        prom (promise)]
