Skip to content

Instantly share code, notes, and snippets.

@lgessler
Created January 15, 2017 01:38
Show Gist options
  • Select an option

  • Save lgessler/c7654f775e670effebd657af9a6f42f2 to your computer and use it in GitHub Desktop.

Select an option

Save lgessler/c7654f775e670effebd657af9a6f42f2 to your computer and use it in GitHub Desktop.
;; not modularized but is DRY as far as subs go
(defn top []
(fn []
(let [foo (sub [:foo])
bar (sub [:bar])]
[:div
[:span (str @foo @bar)]
[:span @foo]])))
;; modularized but you have to repeat subs
(defn sub1 [] (fn [] [:span (str @(sub [:foo]) @(sub [:bar]))]))
(defn sub2 [] (fn [] [:span (str @(sub [:foo]))]))
(defn top [] (fn [] [:div sub1 sub2]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment