May 2018
Beginner to intermediate
290 pages
6h 43m
English
The Clojure language plugin for the LightTable text editor shows off a great example of using an atom to track some fairly complex data.[31] [32] In this case it’s configuration data:
| | ;; Lots of code omitted. |
| | |
| | (def my-settings (atom {:name "clj" |
| | :dir (fs/absolute-path fs/*cwd*) |
| | :type "lein-light-nrepl" |
| | :commands [:editor.eval.clj |
| | :editor.clj.doc |
| | :editor.cljs.doc |
| | :editor.clj.hints |
| | |
| | ;; Many keywords omitted... |
| | |
| | :editor.eval.cljs |
| | :cljs.compile]})) |
| | ;; Lots of code omitted. |
| | |
| | (defn settings! [setts] |
| | (swap! my-settings merge setts)) |
Here we start with an atom containing a map of program settings along with a function that lets us merge new settings into the map. Anytime we need one of the settings, ...
Read now
Unlock full access