Skip to content

Instantly share code, notes, and snippets.

@joncol
Last active March 22, 2019 13:59
Show Gist options
  • Save joncol/fecacf04d1c7c428ad5596aa7fb36710 to your computer and use it in GitHub Desktop.
Save joncol/fecacf04d1c7c428ad5596aa7fb36710 to your computer and use it in GitHub Desktop.
Timed Clojure thingy
(def ^:private credentials-status-atom (atom nil))
(defn- credentials-status []
(when-not @credentials-status-atom
(reset! credentials-status-atom
{:status "awaiting_mobile_bankid_authentication"})
(future
(Thread/sleep 3000)
(reset! credentials-status-atom {:status "updating"}))
(future
(Thread/sleep 6000)
(reset! credentials-status-atom {:status "updated"}))
;; Reset the atom to nil after 2 seconds of `updated` to give test clients
;; some time to react to the status change.
(future
(Thread/sleep 8000)
(reset! credentials-status-atom nil)))
@credentials-status-atom)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment