Last active
July 18, 2017 22:04
-
-
Save ioRekz/9492e01e4819a11ce90ea4961a07de33 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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