A DSL with a View
gbracha.blogspot.com
gbracha.blogspot.com
That dsl is called hiccup, and it's a way to deal with datastructures while building up (usually) html. In the case of reagent, hiccup -> [reagent] -> react-components.
We write functions that return data structures, that get turned into react components.
It's really awesome to be able to treat your UI as data and pure functions that act on data. Any list is simply a formatting function mapped over data at rest, usually a vector of maps.
[1] http://reagent-project.github.io
I'm trying to get into CLJS/Reagent/FRP (quite possibly re-frame) myself.
If you want to checkout some reagent best practices I'd take a look at the re-com live demo, esspecially its source.
Here's the buttons examples in VID...
Rebol []
shrink: does []
grow: does []
view layout [
text "Hello Brave New World"
below ; not really needed as this is the default behaviour
button "Press Me" [shrink]
button "No, press me" [grow]
; row
across
button "Press Me" [shrink]
button "No, press me" [grow]
return
]
VID runs on Rebol 2. Its successor (still in beta) is R3GUI which runs on Rebol 3 - http://www.r3gui.com/This is how the buttons work in R3GUI...
button "Press Me" on-action [shrink]
button "No, press me" on-action [grow]
... which is even more similar to posted article.Below is a basic (ie. naive!) boilerplate of the Todos example code in VID:
todos: ["todo 1" "todo 2" "todo 3"]
;; To be defined!
nothing: []
controls: []
input-zone: []
todo-list: does [
compose [text-list (todos)]
]
footer: does [
either empty? todos [nothing] [controls]
]
view layout compose [
label "todos"
(input-zone)
(todo-list)
(footer)
]
NB. Disclaimer - my VID experience is very limited :)