- Create an app following the official Shadow-CLJS Quick Start instructions.
- Modify
shadow-cljs.edn
;; shadow-cljs configuration
{:source-paths
["src/dev"
"src/main"
"src/test"]
;; ADD - CIDER middleware for nREPL (required by fireplace.vim)
(ns foo.core | |
(:refer-clojure :exclude [slurp])) | |
(defmacro slurp [file] | |
(clojure.core/slurp file)) | |
;; In CLJS | |
(ns bar.core | |
(:require [foo.core :include-macros true :refer [slurp]])) |
shadow-cljs.edn
;; shadow-cljs configuration
{:source-paths
["src/dev"
"src/main"
"src/test"]
;; ADD - CIDER middleware for nREPL (required by fireplace.vim)
Chaining promises in ClojureScript is best done using the thread-first macro, ->
. Here's an example of using the fetch API:
(-> (js/fetch "/data")
(.then (fn [r]
(when-not (.-ok r)
(throw (js/Error. "Could not fetch /data")))
(.json r)))
These resources (articles, books, and videos) are useful when you're starting to learn the language, or when you're learning a specific part of the language. This an opinionated list, no doubt. I've compiled this list from writing and teaching Clojure over the last 10 years.