A small example project in ClojureScript. Fetches train information from rata.digitraffic.fi API and displays it.
- Install the Clojure build tool Leiningen.
- Run
lein figwheel dev
to start the server and a browser - 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/clojurescript_train_radiator/
: the code is hereevents.cljs
subs.cljs
views.cljs
resources/public/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
- add a loading spinner
- make the page prettier (
resources/public/css/style.css
) - make the station configurable (dropdown to app-db or path-parameter)
- show only time table rows for this station
- poll timetables (js/setInterval, dispatch event)
- only show future events (cljs-time,
in-the-future?
) - fetch trains in own API backend (compojure, reitit etc.)
- use Garden for styling instead of plain CSS
- try out re-frame-10x or re-frisk
- localize the project (use tempura)
- browser tests (etaoin)
- collect statistics of late trains
Interactive development means having a REPL (command prompt) where you can interact with the code and try out things, while also running the server.
Here's how:
- Start an interactive clojure environment, for example:
- run
lein repl
in a terminal for plain Clojure orlein figwheel dev
to run Figwheeldev
profile - use
M-x cider-jack-in-clojurescript
in Emacs (after installing cider) - install a Clojure IDE like Cursive for IntelliJ
- run
- Try out things and edit code
- Code is automatically refreshed thanks to Figwheel