A small project in ClojureScript. Fetches R-train information from rata.digitraffic.fi API and displays it in an SVG. A prototype of a real table with LEDs.
- Install the Clojure build tool Leiningen.
- Run
lein figwheel dev
to start the server - Wait a bit, then browse to http://localhost:3449.
- Change the code (browser refreshes automatically thanks to Figwheel)
project.clj
– the configuration file for Leiningensrc/cljs/train_table/core.cljs
– the code is hereresources/public/index.html
– the HTML fileresources/public/css/style.css
: the CSS style file
- ClojureDocs – the Clojure standard library documentation, searchable
- re-frame – the web framework used in this project that does what React and Redux do
- Hiccup wiki – how to generate HTML
- cljs-time – how to handle time
- rata.digitraffic.fi – API for train information
Interactive development means having a REPL (command prompt) where you can interact with the code and try out things, while also running the server.
While you can run Figwheel with lein figwheel dev
you can also run a regular REPL and start Figwheel in it.
- Start an interactive clojure environment, for example:
- run
lein repl
in a terminal - use
M-x cider-jack-in-clojurescript
in Emacs (requires cider) - install a Clojure IDE like Cursive for IntelliJ
- run
- After the REPL is running
(use 'figwheel-sidecar.repl-api)
(start-figwheel!)
- Try out things and edit code
- Code is automatically refreshed thanks to Figwheel
- (Optional) Connect to the browser
(cljs-repl))
- Check that you are there
(.alert js/window "hello from browser")