Skip to content

Instantly share code, notes, and snippets.

@shaunlebron
Created June 26, 2014 20:05
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 shaunlebron/bca0fd36f26dee6fc6dd to your computer and use it in GitHub Desktop.
Save shaunlebron/bca0fd36f26dee6fc6dd to your computer and use it in GitHub Desktop.
problem with using strings as cursors in Om
; Suggested in Om Basic Tutorial for making strings work as cursors
(extend-type string
ICloneable
(-clone [s] (js/String. s)))
(extend-type js/String
ICloneable
(-clone [s] (js/String. s))
om/IValue
(-value [s] (str s)))
(def app-state (atom {:text "Foo"}))
(om/root
(fn [app owner]
(dom/h1 nil
(let [text (:text app)]
(if (= "Foo" text) "Passed." "Failed."))))
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