Fork me on GitHub
#boot
<
2018-10-28
>
cullan18:10:20

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?

dominicm19:10:22

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

cullan19:10:44

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

cullan19:10:59

Thank you.