In a source file called gui.clj, I define a frame, fr, that holds the window for my application, like this:
(def fr (frame ...))
and a run function that sets up fr and causes it to repaint when data changes, something like this (modeled on scribble.clj:
(defn run []
(-> fr add-behaviors pack! show!)
(when-data-changes
(swap! state assoc :shapes (dot/g->seesaw t/ws))
(repaint! fr)))
As I'm messing around in the REPL, I often modify a source file and then call c.t.n.repl/refresh. When I run run again, it puts up a new window, leaving the old window on the screen. How can I make my (newly updated) code operate on the same window even after a refresh?
It sounds like you want to have a bit of a "lifecycle" for the stateful parts of your program, somewhat like
and would like this to happen when you reload. You can have the same window continue to exist and get new contents by adding code to your clean-it-up function that clears the window, or you can close the window and create a new one for each cycle.
I have used the component library for larger projects using this style and it was very effective, though it's a bit of a lifestyle change to get used to it. for your case you may just want to initialize an atom fro store the active window then define the three basic lifecycle functions that opperate on that atom's contents. (and put the actual atom in a
defonce)