0

I have a clj file which defines a schema. There are about 3 or 4 files that depend on the definition of that schema to generate functions. I would like it so that whenever the schema file changes, the dependent files are automatically reevaluated within the repl.

This is quite useful because re-evaluation is also needed when macros are changed. I've looked at load-file but I don't think it does the trick. Are there any suggestion of how might one go about doing this?

I want to manually trigger a commented out form in A. Files B, C, D have a dependency on A. If A changes then B, C, D gets evaluated.

:reload-all does the reverse, ie. A has a dependency on B, C and D and will evaluate all it's dependents.

zcaudate
  • 13,998
  • 7
  • 64
  • 124
  • 1
    There's `(require ... :reload-all)` that might help – Jochen Bedersdorfer Mar 23 '20 at 19:04
  • I don't think this works. – zcaudate Mar 23 '20 at 22:13
  • 1
    Right, `:reload-all` is sorta for the opposite problem: reloading all namespaces depended on by a particular namespace. The question is rather about reloading all namespaces that depend on a particular namespace, and in general this is not something the runtime keeps track of. – amalloy Mar 23 '20 at 22:42

1 Answers1

1

I have a template project set up here:

It uses the lein-test-refresh plugin so that changed files are automatically reloaded upon each editor save, and then all unit tests are re-run. IMHO this is even better (& faster!) than experimenting in the REPL. The Koacha tool has similar capabilities.

You can also see this answer re :reload-all.

Alan Thompson
  • 29,276
  • 6
  • 41
  • 48
  • I accepted an answer on the :reload-all but I don't think it works the way I've described. I've put more in the description. I think lein-test-refresh would work but I'd like to manually trigger it. – zcaudate Mar 23 '20 at 22:22