Guest User

Untitled

a guest
Sep 7th, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (ns hello_seymore.core
  2.   (:require [sablono.core :as sab]))
  3.  
  4. (defonce app-state (atom {:likes 0})) ;that way figwheel will not ruin your state on reload
  5.  
  6.  
  7. (defn like-seymore [data]
  8.   (sab/html [:div
  9.              [:h1 "Behold. The mighty counter. Clicked " (:likes @data) " times"]
  10.              [:div [:a {:href "#"
  11.                         :onClick #(swap! data update-in [:likes] inc)}
  12.                     "Click it"]
  13.                    [:a {:href "#" :onClick #(swap! data update-in [:likes] dec)} "Dec it"] ]]))
  14.  
  15.  
  16.  
  17. (defn render! []
  18.   (.render js/React
  19.            (like-seymore app-state)
  20.            (.getElementById js/document "app")))
  21.  
  22.  
  23. (add-watch app-state :on-change (fn [_ _ _ _] (render!)))
  24.  
  25. (render!)
Advertisement
Add Comment
Please, Sign In to add comment