tolitius / mount

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

Restarting depending state on state's namespace reloading #88

Closed edvorg closed 4 years ago

edvorg commented 7 years ago

Hi. Couldn't find anything in readme about such feature. The idea is that I have some state (com.a/A) that is calculated somehow based on value of other state (com.b/B). Is it possible to restart com.a/A when I reload namespace com.b that is holding state B?

tolitius commented 7 years ago

it could be related to #48 where you would be able to provide dependencies manually.

since mount does not build a dependency graph, it would only see states that belong to a namespace that is being reloaded. i.e. it would restart all the states in #'com.b, but would not know to restart states in #'com.a.

you can of course do:

(mount/stop #'com.b/B #'com.a/A)
(mount/start #'com.a/A #'com.b/B)

but this is not what you're looking for.

I believe mount-lite does build a real graph, you could definitely ask @aroemers he is very good at responding.

Introducing a real dependency graph has benefits and disadvantages. For example one of the benefits would be to start all the states "up-to" #'app/foo (that mount-lite does). Or restart all the transitive dependencies of the namespace that is being reloaded. However it adds a lot of complexity and uncertainties into mount internals, which I'd like to avoid.

edvorg commented 7 years ago

Thank you!

On Thu, Aug 17, 2017, 11:54 AM Anatoly notifications@github.com wrote:

it could be related to #48 https://github.com/tolitius/mount/issues/48 where you would be able to provide dependencies manually.

since mount does not build a dependency graph, it would only see states that belong to a namespace that is being reloaded. i.e. it would restart all the states in #'com.b, but would not know to restart states in #'com.a .

you can of course do:

(mount/stop #'com.b/B #'com.a/A) (mount/start #'com.a/A #'com.b/B)

but this is not what you're looking for.

I believe mount-lite https://github.com/aroemers/mount-lite does build a real graph https://github.com/aroemers/mount-lite/blob/2.x/src/mount/extensions/explicit_deps.clj, you could definitely ask @aroemers https://github.com/aroemers he is very good at responding.

Introducing a real dependency graph has benefits and disadvantages. For example one of the benefits would be to start all the states "up-to"

'app/foo (that mount-lite does). Or restart all the transitive

dependencies of the namespace that is being reloaded. However it adds a lot of complexity and uncertainties into mount internals, which I'd like to avoid.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tolitius/mount/issues/88#issuecomment-322968667, or mute the thread https://github.com/notifications/unsubscribe-auth/ABbhyyc47JfgTu6bknuDRex-LQw5n3x9ks5sY8eegaJpZM4O4jdU .

-- Best regards, Edward Knyshov.