Skip to content

Instantly share code, notes, and snippets.

@ioRekz
Last active July 18, 2017 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ioRekz/9492e01e4819a11ce90ea4961a07de33 to your computer and use it in GitHub Desktop.
Save ioRekz/9492e01e4819a11ce90ea4961a07de33 to your computer and use it in GitHub Desktop.
(require '[reagent.core :as reagent])
(require '[cljs.core.async :as async :refer [<! >!]])
(require-macros '[cljs.core.async.macros :refer [go go-loop]])
(def increment-chan (async/chan))
(def counter
(reagent/atom 1))
(defn increment []
(async/put! increment-chan 1))
(defn slow-counter []
[:div
[:div "Current value counter: " @counter]
[:button {:onClick increment} "Increment"]])
(go
(while true
(<! increment-chan)
(swap! counter inc)
(<! (async/timeout 2000))))
(reagent/render [slow-counter] js/klipse-container)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment