Skip to content

Instantly share code, notes, and snippets.

@isaksky
Created August 12, 2015 14:38
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save isaksky/8c385b4d0024e5116716 to your computer and use it in GitHub Desktop.
Om state test
(defonce app-state (atom {:text "51"}))
(om/root
(fn [data owner]
(reify om/IRender
(render [_]
(dom/div nil
(dom/p nil "Enter some numbers:")
(dom/input #js {:value (:text data)
:onChange (fn [e]
(let [input-txt e.target.value
input-number (first (re-seq #"\d+" input-txt))]
(om/update! data [:text] input-number)))})
(dom/pre nil "Value: " (pr-str (:text data)))))))
app-state
{:target (. js/document (getElementById "app"))})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment