A short series of tutorials on ClojureScript
Clojure CSS JavaScript
Pull request Compare This branch is 1448 commits behind magomimmo:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



A series of tutorials to guide you in creating and setting up ClojureScript (CLJS) projects.


This series of tutorials will guide you in creating, setting up and running simple CLJS projects. The series follows a progressive enhancement of projects themselves.

Assuming you already have installed leiningen 2, to run the last available tutorial without coding:

  1. $ git clone https://github.com/magomimmo/modern-cljs.git
  2. $ cd modern-cljs
  3. $ lein ring server-headless
  4. open a new terminal and cd in modern-cljs
  5. $ lein cljsbuild once
  6. $ lein trampoline cljsbuild repl-listen
  7. visit login-dbg.html and/or shopping-dbg.html
  8. play with the repl connected to the browser

NOTE 1: If you want to access the code of any single tutorial because you don't want to copy&paste it or you don't want to write it yourself, do as follows:

  • $ git clone https://github.com/magomimmo/modern-cljs.git
  • $ cd modern-cljs
  • $ git checkout tutorial-01 # for tutorial 1, tutorial-02 for tutorial 2 etc.

That said, I suggest coding yourself the content of the tutorials. In my experience is always the best choice if you are not already fluent in the programming language you have under your fingers.

Tutorial 1 - The basic

In the first tutorial you are going to create and configure a very basic CLJS project.

Tutorial 2 - Browser CLJS REPL (bREPL)

In this tutorial you are going to set up a browser connected CLJS REPL (bRepl) using an external http-server.

Tutorial 3 - CLJ based http-server

In this tutorial you are going to substitute the external http-server with ring, a CLJ based http-server.

Tutorial 4 - Modern ClojureScript

In this tutorial we start having some fun with CLJS form validation, by porting from JS to CLJS the login form example of Modern Javascript: Development and design by Larry Ullman.

Tutorial 5 - Introducing Domina

In this tutorial we're going to use domina library to make our login form validation more clojure-ish.

Tutorial 6 - Easy made Complex and Simple made Easy

In this tutorial we're going to investigate and solve in two different ways the not so nice issue we met in the last tutorial.

Tutorial 7 - On being doubly aggressive

In this tutorial we're going to explore CLJS/CLS compilation modes by using the usual lein-cljsbuild plugin of leiningen, but we'll discover a trouble we'll solve by using a new feature of the 0.3.0 of lein-cljsbuild plugin.

Tutorial 8 - Introducing Domina events

In this Tutorial we're going to introduce domina events which, by wrapping Google Closure Library event management, allows to follow a more clojure-ish approach in handing DOM events.

Tutorial 9 - DOM Manipulation

In this tutorial we'are going to face the need to programmatically manipulate DOM elements as a result of the occurrence of some DOM events.

Tutorial 10 - Introducing Ajax

In this tutorial we're going to extend our comprehension of CLJS by introducing Ajax to let the CLJS client-side code to communicate with the CLJ server-side code.

Tutorial 11 - A deeper understanding of Domina events

In this tutorial we're going to enrich our understanding of Domina events by applying them to the login form example we introduced in the 4th Tutorial.

Tutorial 12 - The highest and the deepest layers

In this tutorial we're going to cover the highest and the deepest layers of the Login Form example we started to cover in the previous tutorial.

Tutorial 13 - Don't Repeat Yourself while crossing the border

One of our long term objectives is to eliminate any code duplication from our web applications. That's like to say we want firmly stay as compliant as possible with the Don't Repeat Yourself (DRY) principle. In this tutorial we're going to respect the DRY principle by sharing validators between the client (i.e. CLJS) and the server (i.e. CLJ).

Tutorial 14 - It's better to be safe than sorry (Part 1)

In this tutorial we are going to prepare the stage for affording the unit testing topic. We'll also introduce the Enlive template sytem to implement a server-side only version of the Shopping Calculator aimed at adhering to the progressive enanchement implementation strategy. We'll even see how to exercize code refactoring to satisfy the DRY principle and to solve a cyclic namespaces dependency problem.

Tutorial 15 - It's better to be safe than sorry (Part 2)

In this tutorial, after having added the validators for the shoppingForm, we're going to introduce unit testing.

Tutorial 16 - It's better to be safe than sorry (Part 3)

In this tutorial we make unit testing portable from CLJ to CLJS (and vice-versa) by using the clojurescript.test lib and the cljx lein plugin.

Tuturial 17 - Enlive by REPLing

To be respectful with the progressive enhancement strategy, in this tutorial we're going to integrate the form validators for the server-side Shopping Calculator into the corresponding WUI (Web User Interface) in such a way that the user will be notified with the right error messages when the she/he types in invalid values in the form.


Copyright © Mimmo Cosenza, 2012-2013. Released under the Eclipse Public License, the same as Clojure.