SHARE
TWEET

Untitled

a guest Jan 11th, 2017 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (ns om-tutorial.part
  2.   (:require
  3.     goog.debug.formatter
  4.     goog.debug.RelativeTimeProvider
  5.     [goog.dom :as gdom]
  6.     [om.next :as om :refer-macros [defui]]
  7.     [om.dom :as dom]))
  8.  
  9. (def app-state (atom {:count 0}))
  10.  
  11. (defui Counter
  12.   Object
  13.   (render [this]
  14.           (let [{:keys [count]} (om/props this)]
  15.             (dom/div nil
  16.                      (dom/span nil (str "Count: " count))
  17.                      (dom/br nil nil)
  18.                      (dom/button
  19.                        #js {:onClick
  20.                             (fn [e]
  21.                               (swap! app-state update-in [:count] inc))}
  22.                        "Click me!")))))
  23.  
  24. (def reconciler
  25.   (om/reconciler {:state app-state}))
  26.  
  27. (om/add-root! reconciler
  28.               Counter js/klipse-container)
RAW Paste Data
Top