boot

:boot-clj: https://boot-clj.github.io/ — build tooling for Clojure. Dev chat in #boot-dev
cullan 2018-10-28T18:49:20.005400Z

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?

dominicm 2018-10-28T19:24:22.006500Z

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

cullan 2018-10-28T19:26:44.007300Z

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

cullan 2018-10-28T19:26:59.007500Z

Thank you.