Skip to content

Instantly share code, notes, and snippets.

@mynomoto
Last active November 17, 2023 11:11
Show Gist options
  • Select an option

  • Save mynomoto/dba41fccf1af9d48793142743f8da909 to your computer and use it in GitHub Desktop.

Select an option

Save mynomoto/dba41fccf1af9d48793142743f8da909 to your computer and use it in GitHub Desktop.
(ns view.index
(:require
[hoplon.core :as h]
[javelin.core :as j]))
(def a (j/cell 42))
(def b (j/cell {:x 100 :y 200}))
(def formulet-test
(j/formulet [v (j/cell= (inc a))
w (+ 1 2)
{:keys [x y]} b]
(+ v w x y)))
(defn formulet-example
[]
(h/div
(h/h2 "formulet")
; we should see the formulet value below
(h/div (h/text "formulet value: ~{formulet-test}"))
(h/button :click #(swap! a inc) "a++")
(h/button :click #(swap! a dec) "a--")
(h/button :click #(js/console.log formulet-test) "debug formulet")))
(.replaceChildren (.getElementById js/document "app")
(formulet-example))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment