Created
February 27, 2023 03:57
-
-
Save bherrmann7/765f4074dfac013527402fa7f4016ee5 to your computer and use it in GitHub Desktop.
This file contains 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 app.fortune | |
#?(:cljs (:require-macros app.fortune)) | |
(:require #?(:clj [clojure.java.shell :as sh]) | |
[hyperfiddle.electric :as e] | |
[hyperfiddle.electric-dom2 :as dom] | |
[hyperfiddle.electric-ui4 :as ui])) | |
#?(:clj (defn fortune [] (:out (sh/sh "fortune")))) | |
#?(:clj (defonce !x (atom (fortune))) ) | |
(e/def x (e/server (e/watch !x))) | |
(e/defn Fortune [] | |
(e/client | |
(dom/h1 (dom/text "Fortune")) | |
(dom/pre (dom/text (e/server x))) | |
(dom/br) | |
(ui/button (e/fn [] (e/server (reset! !x (fortune)))) (dom/text "New Fortune")))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment