Skip to content

Interact with the REPL via your editorλ︎

Hint::λ︎

Your editor should either be running the Clojure/ClojureScript REPL's or connected to the REPLs run with lein figwheel


Note::Edit welcome messageλ︎

Edit the message [:h3] in the hello-world component and see how it changes in the web browser

(defn hello-world []
  [:div
   [:h1 (:text @app-state)]
   [:h3 "Edit this and watch it change!"]])

(defn tictactoe-game []
  [:div
   [:h1 (:text @app-state)]
   [:p "Do you want to play a game?"]])

Note::Change the title by editing the app-stateλ︎

Change the :text message in app-state and see what happens in the browser

(defonce app-state (atom {:text "Hello World"}))

(defonce app-state (atom {:text "Lets Play TicTacToe"}))

When you save a change to the app-state nothing happens in the browser.

As we use defonce rather than def, then Clojure does not update the definition if it already exists. This prevents your app state from being cleared every time you save a change in your editor.

To see the change of a defonce you need to refresh your browser page.