Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

README: Add warnings about helper functions

  • Loading branch information...
commit 0f192e2fef606afbd1dd76b458c906f7d89a3683 1 parent 47a1e12
Stuart Sierra stuartsierra authored
Showing with 19 additions and 1 deletion.
  1. +19 −1 README.md
20 README.md
View
@@ -230,7 +230,8 @@ Step 5. Restart:
user=> (def my-app (create-application))
user=> (start my-app)
-(You could also combine all those steps in a single utility function.)
+(You could also combine all those steps in a single utility function,
+but see warnings below.)
After that, you've got a squeaky-clean new instance of your app
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.
If you create your own instance of the dependency tracker, do not
store it in a namespace which gets reloaded.
+### Warnings for Helper Functions
+
+Be careful defining a helper function in a namespace which calls
+`refresh` if that namespace also could get reloaded. For example, you
+might try to combine the stop-refresh-start code from the "Managed
+Lifecycle" section into a single function:
+
+ (defn restart []
+ (stop my-app)
+ (refresh)
+ (def my-app (create-application))
+ (start my-app))
+
+This won't work if the namespace containing `restart` could get
+reloaded. After `refresh`, the namespace containing `restart` has been
+dropped, but the function continues to run in the *old* namespace.
+
### Warnings for Aliases
Namespace aliases created at the REPL will still refer to the *old* namespace after `refresh`. For example:
Please sign in to comment.
Something went wrong with that request. Please try again.