tolitius / mount

managing Clojure and ClojureScript app state since (reset)
Eclipse Public License 1.0
1.22k stars 88 forks source link

Allowing specification of dependencies of a state #71

Closed gja closed 6 years ago

tolitius commented 7 years ago

Thanks for the time spent on this :)

This problem is not new and there is an open issue that tries to start the discussion about deps.

Concerns

There are a couple of problems with the proposed solutions:

(defstate conn :deps [#'config]
               :start (create-connection config))

i.e. what if a state had three deps, we would need 6 mentions, 3 of which would be duplicates.

:deps on the defstate level adds complexity, since now it is not just start and stop, and on every start, and potentially in some cases on stop, :deps need to be taken to the count, not only by mount, but also by a developer.

Current Thinking

A concern such as identifying dependencies for a component / state should be cross cutting or/and decoupled from the component itself. Possibly a separate function, or a config, that specifies dependencies between states.

Problem Priority

If the only real goal of this is to be able to start a state with having all its dependencies started automatically, the I have two thoughts: