Putting It All Together

Let’s look at an example of a service that has a couple of resources that allow the client to read and write some data. The application will display a list of to-do items and allow the user to add additional items to the list.

The client will be implemented in ClojureScript and use Ajax to communicate with the service. The client code will consist of a few functions to retrieve, render, and save to-do items. Let’s look at each of these in turn.

The first function renders the items in our list.

 (​defn​ item-list [items]
  (when (​not-empty​ items)
  (​for​ [item items]
  ^{:key item}
  [:li item])]))

Next we add a function called get-items to grab the ...

Get Web Development with Clojure, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.