-
-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cljs-ajax, slimmed down #9
Conversation
add externs/main.txt for advanced compilation
I exposed |
@kloimhardt Looks good. |
@kloimhardt I now published an example: |
@borkdude ... aaand there is the combined babashka+scittle Guestbook web-app example. It is here and has only two files: an 80loc backend (based on your since long available template) and the file I hope one day we will see this as the basis of a free-to-read opening chapter of some future edition of the book. |
@kloimhardt This is very exciting, thanks for making this. I will link it from the scittle page. |
I guess the cljs-ajax is kind of redundant now that all major browsers support the fetch API. That didn't occur to me a year ago. |
This is an example of the fetch API: <html>
<head>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/scittle.js" type="application/javascript"></script>
<script type="application/x-scittle">
(defn handler [response]
(js/alert (str response)))
(defn make-request []
(-> (js/fetch "index.html")
(.then #(.text %))
(.then #(js/alert %))))
;; export function to use from JavaScript:
(set! (.-make_request js/window) make-request)
</script>
</head>
<body>
<button onclick="make_request()">
Click me!
</button>
</body>
</html> |
Looking at your fetch example, it is obvious that removing clj-ajax from the Scittle canon is the way to go. |
exposes to Scittle:
ajax.core/GET
ajax.core/POST
clojure.core/random-uuid
cljs.reader/read-string (-> renamed to) clojure.core/read-string
reagent.core/as-element