Book Image

Clojure Reactive Programming

Book Image

Clojure Reactive Programming

Overview of this book

Table of Contents (19 chapters)
Clojure Reactive Programming
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Bibliography
Index

Building a simple Contacts application with Om


This chapter has been very text heavy so far. It's time we get our hands dirty and build a simple Om application. Since we talked about contacts before, that's what we will start with.

The main driver behind React and Om is the ability to build highly reusable, self-contained components and, as such, even in a simple Contacts application, we will have multiple components working in concert to achieve a common goal.

This is what our users should be able to do in the application:

  • Display a list of contacts currently in storage

  • Display the details of a given contact

  • Edit the details of a specific contact

And once we're done, it will look like the following:

The Contacts application state

As mentioned previously, Om/React will eventually render the DOM based on our application state. We'll be using data that's in memory to keep the example simple. Here's what our application state will look like:

(def app-state
  (atom {:contacts {1 {:id    1
          ...