Skip to content

Instantly share code, notes, and snippets.

@selfsame
Created February 16, 2014 00:50
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 selfsame/9027584 to your computer and use it in GitHub Desktop.
Save selfsame/9027584 to your computer and use it in GitHub Desktop.
om data :fn usage
(sug/defcomp report
[data owner]
{:render-state
(fn [_ state]
(dom/li nil (prn-str (str (rand-int 100)) data) ))})
(sug/defcomp button
[data owner]
{:render-state
(fn [_ state]
(dom/ul nil
(sug/make report (:neg data) {:fn (fn [d] (conj d {:odd (filter odd? (:vals d))}))})
(sug/make report (:pos data) {})
))})
(sug/defcomp router
[data owner]
{:render-state
(fn [_ state]
(dom/div nil
(sug/make button data {:fn (fn [d] (conj d {:neg {:vals (filter neg? (:things d) )}}) )})
(sug/make button data {:fn (fn [d] (conj d {:pos {:vals(filter pos? (:things d) )}}) )})
(dom/hr nil "")
)) })
(def DAT (atom {:things [2 4 6 8 -2 -4 -6 -8] :neg {:vals []} :pos {:vals []}}) )
(om/root DAT router (.getElementById js/document "main"))
DAT
(swap! DAT update-in [:things] #(conj % 3))
(swap! DAT update-in [:things 0] #(* % -1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment