Last active
June 12, 2017 08:48
-
-
Save tiye/8a51c0e03ca7ec55d1c257f60edf01c5 to your computer and use it in GitHub Desktop.
Exploring if I can get Respo component simpler. Tried in Lumo.
This file contains hidden or 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 demo.a | |
(:require demo.b) | |
(:require-macros [demo.b :refer [defcomp]])) | |
(println (macroexpand '(defcomp my-comp [x y] 1))) | |
(defcomp my-comp [x y] 1) | |
(println my-comp) |
This file contains hidden or 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 demo.b) | |
(defn create-comp [comp-name body] | |
[comp-name body]) | |
(defmacro defcomp [comp-name params & body] | |
`(def ~comp-name | |
(create-comp ~(keyword comp-name) | |
(~'fn [~@params] | |
(~'fn [~'cursor] ~@body))))) |
This file contains hidden or 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
(def comp-demo | |
(create-comp :demo | |
(fn [content] | |
(fn [cursor] | |
(div | |
{:class-name "demo-container" | |
:style {:color :red}} | |
(comp-text content nil)))))) | |
This file contains hidden or 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
=>> lumo -c src/ -i src/demo/a.cljs | |
(def my-comp (demo.b/create-comp :my-comp (fn [x y] (fn [cursor] 1)))) | |
[:my-comp #object[Function "function (x,y){ | |
return (function (cursor){ | |
return (1); | |
}); | |
}"]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment