Created
July 18, 2024 09:06
-
-
Save henrik42/f9e1977a35380bb28829c06301509841 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| {:name "scittle-example-1"} | |
| ;;--- | |
| (ns example-1) | |
| (def app (js/document.createElement "div")) | |
| (js/document.body.appendChild app) | |
| (defn load-script [src callback-str] | |
| (js/console.log (str "load-script: src=" src " callback=" callback-str)) | |
| (js/document.body.appendChild | |
| (doto (js/document.createElement "script") | |
| (.setAttribute "onLoad" (str "scittle.core.eval_string(\"" callback-str "\")")) | |
| (.setAttribute "src" src)))) | |
| (defn load-reagent [] | |
| (load-script "https://unpkg.com/react@17/umd/react.production.min.js" | |
| "(example-1/load-reagent-dom)")) | |
| (defn load-reagent-dom [] | |
| (load-script "https://unpkg.com/react-dom@17/umd/react-dom.production.min.js" | |
| "(example-1/load-scittle-reagent)")) | |
| (defn load-scittle-reagent [] | |
| (load-script "https://cdn.jsdelivr.net/npm/scittle@0.6.17/dist/scittle.reagent.js" | |
| "(example-1/main)")) | |
| (defn page [] | |
| "Hello world!") | |
| (def loader " | |
| (require '[reagent.core :as r]) | |
| (require '[reagent.dom :as rdom]) | |
| (rdom/render [page] app) | |
| ") | |
| (defn main [] | |
| (js/scittle.core.eval_string loader)) | |
| (load-reagent) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment