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) |
| [:ul |
| (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 books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.