tolitius / mount

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

":with-deps" to manually override the start order / dependencies #48

Open tolitius opened 8 years ago

tolitius commented 8 years ago

In case of indirect dependencies sometimes it is needed to specify a particular order in which they start.

For example if we have a message bus and a subscriber that are indirectly connected via, say, a core.async channel, we need to make sure the subscriber does not start subscribing to the message bus before the bus is started.

It is not a simple task to validate the dependency order just for indirect dependencies:

i.e. in case a state a is "enriched" with a dependency on state b, how do we know that by starting b a bit ​earlier​, to satisfy this dependency, we not hurting it (b) by now not ​yet​ starting states that b naturally depends on

since mount records only a linear dependency / start order.

Therefore the idea (that belongs to @wkf) is to optionally specify all the dependencies on mount start e.g.:

(mount/start-with {:with-deps {... dependency graph / order ...}})

This has to do with start-with rebranding #47, and, as a side effect, will add more dependency graph explicitness.