Fork me on GitHub

I am having trouble with boot-reload in my clojurescript project. I am storing the game state in an atom. I want the game to reset to the starting state upon reload. The game loop uses setInterval to make a timer. When my code reloads it seems to wipe out the game state before calling my function that I set with on-jsload and that makes me lose track of the timer. Is there a way to run a function to clear the game state before reloading?


@clojureslack how is your atom defined? I believe defonce for the atom instead of def will do what you want.


@dominicm Yes! That fixed it. It makes sense too. I was defining the atom with def so it was recreating it when it reloaded.