Why should i use Mount or Component

Using mount or one of the other libraries for stateful components is not strictly necessary. What they give you is a way to tear down and rebuild the stateful parts of your application without restarting the REPL. You might have seen this old blog post by Stuart Sierra on the reloaded workflow, which inspired these systems: http://thinkrelevance.com/blog/2013/06/04/clojure-workflow-reloaded

I usually encapsulate the database connection pool in one component, the web server in another, and declare the database component a dependency of the web server component.

I think I saw another topic here on Clojureverse with some discussion on the pros and cons of component systems. Some alternatives were also highlighted in that topic, e.g. using delay for encapsulating components.

Edit:

Found the topic: How to manage database connection in Clojure? . Look at the comments by @didibus for a description of using delay and promise in this context.

1 Like