Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Added and

  • Loading branch information...
commit 8dd2f97ffc8eb17fe3af38331114cf461451f83c 1 parent 06d44dc
@danskarda danskarda authored
Showing with 73 additions and 18 deletions.
  1. +58 −0
  2. +15 −18
@@ -0,0 +1,58 @@
+# Adding ClojureScript to Chat Room Demo
+In the last iteration of our demo we add ClojureScript to improve our
+(simple chat server)[demo/demo-3-chat]. We will poll server using XhrIo
+request to fetch new chat room messages without page refresh.
+We use [lein-cljsbuild]( Leiningen
+plugin to integrate ClojureScript to our project. See [project.clj](project.clj)
+for changes and cljsbuild configuration.
+Type `lein cljsbuild once` to compile .cljs files to JavaScript.
+To modify our ClojureScript life in the browser, we can also start ClojureScript
+REPL using `lein cljsbuild repl-listen`. This command will listen for repl
+request on port 9000. Then we need to connect the browser.
+Once we compile ClojureScript files, we can launch Jetty web server, point
+our browser to main page and enter a chat room. Then we launch JavaScript developer
+console in Chrome and type `demo.repl.start_repl ()`.
+Crossovers in Cljsbuild enable code sharing between Clojure and
+ClojureScript. ClojureScript files are stored in [src-cljs/](src-cljs)
+directory, crossovers are in stored in [src/](src) directory and
+configured in [project.clj](project.clj) file.
+We will use crossover functionality to share message rendering in
+[message.clj](src/demo/message.clj). Output from function `render-message`
+can be rendered into HTML by both Hiccup library and `clojure.browser.dom`.
+Extending server
+To enable ClojureScript polling we performed two changes to [core.clj](src/demo/core.clj):
+* `(resources "/")` to serve compiled JavaScript files from resources/ directory.
+* we added api-routing to fulfill browser polling requests.
+In [page.clj](src/demo/page.clj) we included JavaScript and added new attributes
+to identify messages from JavaScript.
+Server polling from browser
+ClojureScript uses [Google Closure]( library.
+We use `` and `goog.Timer` to build simple polling mechanism.
+`clojure.browser.dom`, `net` and `event` libraries are simple ClojureScript wrappers around
+Google Closure functionality.
@@ -1,25 +1,22 @@
-# demo
+# Clojure & Web - simple Demo
+The code in this repo was part of 'Clojure & Web' talk prepared by
+[Daniel Skarda]( See [Google Presentation]( for slides.
-For the second demo we included two libraries: hiccup and
+The talk was presented on [Prague Lambda Meetup](
+on September 26th 2012.
+The goal of the talk was to give an overview of Clojure libraries for
+* simple request handling (see (Demo 1)[demo/demo-1-jetty])
+* HTML generation using [Hiccup](
+* request routing using [Compojure]( (see (Demo 2)[demo-2-compojure] and (Demo 3)[demo-3-chat]).
+* using ClojureScript for browser specific tasks
+* deploying on Heroku
+See demos in [demo/](demo/) directory and []( for description of last demo.
-For easier request handling we also added ring-core and
-ring-devel. Both include definition of ring "middleware".
-Hiccup is a library for HTML rendering from Clojure data
-Is a DSL (Domain Specific Language) for writing routing
-information for Ring.
Please sign in to comment.
Something went wrong with that request. Please try again.