             (recur (<! (timeout 20)) out)
             (when-done out))))))
 
-
-(defn looper-OLD
-  [initial-value func continue?]
-  (reset! continue? true)
-  (go (loop [pause (<! (timeout 20))
-             val   initial-value]
-        (let [out  ((func continue?) val)]
-          (if @continue?
-            (recur (<! (timeout 20)) out)
-            out)))))
 
 
 ;; ------------------------------------------------------------------------------------

  .                to be used for the subsequent function call and so on.
  - running?       A reagent boolean atom indicating if the processing is running
  "
  (let [schedule (fn reschedule [state]
                   (js/setTimeout
                    #(let [next-state (apply (func) state)]
                       (util/console-log (str "IN reschedule: " state))
                       (when-not next-state (reset! running? false))
                       (when @running? (reschedule next-state)))
                    20))] ;; 20ms should give enough time for UI events to be processed
    (reset! running? true)
    (schedule initial-state)))


;; ------------------------------------------------------------------------------------
;;  looper
;; ------------------------------------------------------------------------------------

(defn looper
  [& {:keys [initial-value func when-done]}]
  (go (loop [pause (<! (timeout 20))
             val   initial-value]
        (let [[continue? out]  (func val)]

  Parameters:
  - markup  The message to display in the modal (a string or a hiccup vector or function returning a hiccup vector)
  "
  (fn []
    [:div
     {:style {:display "flex"      ;; Semi-transparent backdrop
              :position "fixed"
              :left "0px"
              :top "0px"
              :width "100%"
              :height "100%"
              :background-color "rgba(0,0,0,0.85)"
              :z-index 1020
              :on-click #(util/console-log "clicked backdrop") ;; Gobble up clicks so they don't go to the main window (TODO: Doesn't work)
              }}
     [:div                         ;; Modal window containing div
      {:style {:margin "auto"
               :background-color "white"
               :padding "16px"
               :border-radius "6px"
               :z-index 1020}}
      markup]]))



;; ------------------------------------------------------------------------------------
;;  looper
;; ------------------------------------------------------------------------------------

(defn looper
  [& {:keys [initial-value func when-done]}]
  "...
  Parameters:
  - func           A function to repeatedly call. On each call, something else happens, could be the
