Created
February 4, 2017 17:20
-
-
Save Conaws/0d63855567da4c96596819c9d27e7672 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns re-kindle.util | |
(:require [reagent.core :as r])) | |
(defmacro deftrack [name params* & body] | |
`(def ~name | |
(partial r/track (fn ~params* ~@body)))) | |
;;; example-usage | |
(deftrack sum-track [vector-atom] | |
(reduce + @vector-atom)) | |
(defn sum-example [] | |
(let [vatom (r/atom [1 2 3 4]) | |
sum-atom (sum-track vatom)] | |
(fn [] | |
[:div | |
(pr-str @vatom) | |
(pr-str @sumatom) | |
[:button {:on-click #(swap! vatom conj (rand 10))}] | |
] | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment