Skip to content

Getting started

candera edited this page Jan 3, 2012 · 21 revisions

Getting Started

To install ClojureScript One, install leiningen, clone ClojureScript One and, from within the cloned directory, run script/deps.

git clone https://github.com/brentonashworth/one.git
cd one
script/deps
script/run

The four commands above will install everything and start the server. You may view the running application by visiting http://localhost:8080.

Clojure REPL

The script/run script will start the server and also start a properly classpathed Clojure Read-eval-print-loop (REPL). To start a Clojure REPL without starting the server, use script/repl. This REPL may be used to interact with the server.

To interact with the running ClojureScript application, you will need to start a ClojureScript REPL. There are two ways to do this: manually from the Clojure REPL or automatically by running script/cljs-repl. The cljs-repl script will start a ClojureScript REPL and open your default browser to the ClojureScript application in order to establish a connection.

Manually starting the server

script/run starts a Clojure REPL and the server. To manually start the server, use script/repl and then evaluate the following forms.

(use '[one.sample.dev-server :only (run-server)])
(run-server)

Manually starting a ClojureScript REPL

From a Clojure REPL, you may start a ClojureScript REPL by evaluating:

(use '[one.sample.dev-server :only (cljs-repl)])
(cljs-repl)

About the ClojureScript REPL

A ClojureScript REPL allows you to evaluate forms in the running ClojureScript application. Starting a working ClojureScript REPL is a two step process. You first need to start the REPL process and then you need to connect it to the browser. To connect, visit http://localhost:8080 and click the Development button. If you are already on this page then you will need to refresh it. Each time you start a ClojureScript REPL you will need to either go to or refresh this page.

The ClojureScript REPL will only work when running the development version of the application. Neither the design nor the production view connects to the REPL.

The cljs-repl script was created to make the connection process more convenient.

Testing your connection

With your browser window in view, evaluate the following forms to ensure that you are connected and to experience some of the joy of ClojureScript.

(js/alert "hello")
(in-ns 'one.sample.view)
(set-text! (by-id "header") "The Form")
(set-styles! (by-id "header") {:color "#FF0000" :font-size "138px"})

Entering :cljs/quit in the ClojureScript REPL will stop this REPL and put you back in the Clojure REPL. In this way, one can quickly switch between the Clojure and ClojureScript REPL when working on the client and server portions of an application.

Clone this wiki locally