Clojure Mount

Once you learn Clojure (or any programming language) well enough to tackle a large project, you are going to run into lifecycle, dependency, and state management issues.

Two great resources for handling lifecycles, dependency, and state in Clojure apps are Mount and Component. I use Mount for my projects, but both are popular solutions. This post is about tolitius/Mount.

Simple Mount Example

The first step in using any Clojure library is to include it as a dependency in your project. I’m using lein, so the project.clj needs the Mount dependency.

You can find the latest dependency code by searching for ‘clojars’ on the Mount project page.

Next, we need some sample code. How about a stateful thread?

Now for a main method to use the stateful dependency.

Running this code should result in output similar to the following

This is a very basic example that should be easy to expand upon.

Leave a Reply

Your email address will not be published. Required fields are marked *