Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

States using {:on-reload :noop} that are reloaded while running remain stale after manual restart #105

Open
krajj7 opened this issue Dec 30, 2018 · 1 comment

Comments

@krajj7
Copy link
Contributor

krajj7 commented Dec 30, 2018

This is a bit of a feature request, since the current behavior does make some sense, but in my opinion it could be improved.

If you have a running state marked {:on-reload :noop} (to prevent auto-restarts), when you reload your code and later manually stop and restart the state, mount will keep starting the old version of the state, rather than using the newly loaded code.

While keeping the old version running is expected (with {:on-reload :noop}), I think it would be really nice if mount would remember the start/stop functions of the most recently loaded version, and use those after the old state was manually stopped. Currently you need to remember to reload only when the state is stopped to make your new code active.

Example REPL session is below. Ideally you'd get the new version of the state at the end (which is what you'd get if the state was stopped when it was redefined).

boot.user=> (require '[mount.core :as mount])

boot.user=> (mount/defstate ^{:on-reload :noop} teststate :start "old version" :stop (println "old version stopped"))
#'boot.user/teststate

boot.user=> (mount/start)
{:started ["#'boot.user/teststate"]}

boot.user=> teststate
"old version"

; simulating code reload by redefining the state
boot.user=> (mount/defstate ^{:on-reload :noop} teststate :start "new version" :stop (println "new version stopped"))
#'boot.user/teststate

boot.user=> (mount/stop)
old version stopped
{:stopped ["#'boot.user/teststate"]}

boot.user=> (mount/start)
{:started ["#'boot.user/teststate"]}

boot.user=> teststate
"old version"
krajj7 added a commit to krajj7/mount that referenced this issue Jan 1, 2019
@tolitius
Copy link
Owner

tolitius commented Jan 4, 2019

I believe that :noop should be exactly that: no operation. If life cycle fns need to be updated and applied after reload, it is no longer a :noop.

let me sleep/think on it a little.

thanks for catching this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants