Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

README: Add warnings about helper functions

  • Loading branch information...
commit 0f192e2fef606afbd1dd76b458c906f7d89a3683 1 parent 47a1e12
Stuart Sierra stuartsierra authored

Showing 1 changed file with 19 additions and 1 deletion. Show diff stats Hide diff stats

  1. +19 1 README.md
20 README.md
Source Rendered
@@ -230,7 +230,8 @@ Step 5. Restart:
230 230 user=> (def my-app (create-application))
231 231 user=> (start my-app)
232 232
233   -(You could also combine all those steps in a single utility function.)
  233 +(You could also combine all those steps in a single utility function,
  234 +but see warnings below.)
234 235
235 236 After that, you've got a squeaky-clean new instance of your app
236 237 running, in a fraction of the time it takes to restart the JVM.
@@ -307,6 +308,23 @@ references to things you created in the REPL.
307 308 If you create your own instance of the dependency tracker, do not
308 309 store it in a namespace which gets reloaded.
309 310
  311 +### Warnings for Helper Functions
  312 +
  313 +Be careful defining a helper function in a namespace which calls
  314 +`refresh` if that namespace also could get reloaded. For example, you
  315 +might try to combine the stop-refresh-start code from the "Managed
  316 +Lifecycle" section into a single function:
  317 +
  318 + (defn restart []
  319 + (stop my-app)
  320 + (refresh)
  321 + (def my-app (create-application))
  322 + (start my-app))
  323 +
  324 +This won't work if the namespace containing `restart` could get
  325 +reloaded. After `refresh`, the namespace containing `restart` has been
  326 +dropped, but the function continues to run in the *old* namespace.
  327 +
310 328 ### Warnings for Aliases
311 329
312 330 Namespace aliases created at the REPL will still refer to the *old* namespace after `refresh`. For example:

0 comments on commit 0f192e2

Please sign in to comment.
Something went wrong with that request. Please try again.