Fork me on GitHub
Luis Santos18:09:21

Hi everyone, I'm currently using nrepl with cider and would like to run a clojure function every time a s-exp is evaluated. I'm working on a cljfx project and I'm trying to get my scene reloaded every time a function is re-evaluated. Does anyone knows where to start? Do I need to build a middleware or is there any to add a hook to my user.clj? Thanks


@luis559 a hook is what you're after I think!

Luis Santos20:09:17

Thanks @U09LZR36F. What hook should I use? Is it an emacs/cider hook or a nrepl client hook or cider-nrepl client hook? Sorry I'm new to the clojure ecosystem and I have to confess I don't know how all the pieces work.


Sorry, I was not 100% when I sent this. A middleware is what I meant to say facepalm


A good example to start from is probably which does something similar to what you want - running a function after evaluation.


Hmm, actually that doesn't work how I expected. Lemme see if I can find you a better example.

dominicm21:09:47 is a pretty close example, but not quite what you're trying to do either. This middleware wraps eval/load-file so that when you call them, the code is wrapped by the library. But instead you just want to call the handler, then run your result, something like:

(let [result (apply handler args)]

Luis Santos09:09:40

Thanks @U09LZR36F. This sounds a great start point. I will have a look. thanks3