     (async/<! (utils/timeout poll-frequency))
     (recur)))
 
-
 (defn- most-recent-build-number [state]
   (->> state
        (map :build-number)


(def poll-frequency 1000)

(defn poll [atom connection-lost-atom fn callback]
  (go-loop []
    (let [new-val (async/<! (fn))]
      (if new-val
        (do
          (reset! connection-lost-atom false)
          (reset! atom new-val)
          (callback new-val))
        (reset! connection-lost-atom true))
      )
    (async/<! (utils/timeout poll-frequency))
    (recur)))

(defn poll-and-dispatch [kw connection-lost-atom fn callback]
  (go-loop []
    (let [new-val (async/<! (fn))]

        state-atom (re-frame/subscribe [:pipeline-state])
        build-number-atom (atom nil)
        step-id-to-display-atom (atom nil)
        output-details-visible (atom false)
        connection-lost-atom (atom false)]
    (poll-history build-number-atom connection-lost-atom)
    (poll-state build-number-atom connection-lost-atom)
    (route/hook-browser-navigation! build-number-atom step-id-to-display-atom state-atom)
    ; #' is necessary so that fighweel can update: https://github.com/reagent-project/reagent/issues/94
    (reagent/render-component [#'root build-number-atom step-id-to-display-atom history-atom state-atom output-details-visible connection-lost-atom history/build-history-component wired-current-build-component header] (.getElementById js/document "app"))))
