Skip to content

Instantly share code, notes, and snippets.

@mynomoto
Last active November 17, 2023 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mynomoto/27e65a9d3c6fc24d59e554d55d84aee3 to your computer and use it in GitHub Desktop.
Save mynomoto/27e65a9d3c6fc24d59e554d55d84aee3 to your computer and use it in GitHub Desktop.
(ns view.index
(:require
[hoplon.core :as h]
[javelin.core :as j]))
(j/defc i 0)
(j/defc j 1)
(j/defc k 2)
(def formula-of-test (j/formula-of [i j k] (+ i j k)))
(defn formula-of-example
[]
(h/div
(h/h2 "formula-of")
(h/div (h/text "i: ~{i} j: ~{j} k: ~{k}"))
; we should be able to see the result after `=`
(h/div (h/text "~{i} + ~{j} + ~{k} = ~{formula-of-test}"))
(h/button :click #(swap! i inc) "i++")
(h/button :click #(swap! i dec) "i--")
(h/button :click #(swap! j inc) "j++")
(h/button :click #(swap! j dec) "j--")
(h/button :click #(swap! k inc) "k++")
(h/button :click #(swap! k dec) "k--")))
(.replaceChildren (.getElementById js/document "app")
(formula-of-example))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment