Skip to content

Instantly share code, notes, and snippets.

@tiye
Last active June 12, 2017 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tiye/8a51c0e03ca7ec55d1c257f60edf01c5 to your computer and use it in GitHub Desktop.
Save tiye/8a51c0e03ca7ec55d1c257f60edf01c5 to your computer and use it in GitHub Desktop.
Exploring if I can get Respo component simpler. Tried in Lumo.
(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)
(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)))))
(def comp-demo
(create-comp :demo
(fn [content]
(fn [cursor]
(div
{:class-name "demo-container"
:style {:color :red}}
(comp-text content nil))))))
=>> 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