Fork me on GitHub
#chestnut
<
2017-11-28
>
cjsauer19:11:38

Hello again fellow chestnuts. I'm having a bit of trouble with live reloading. Specifically, project.clj has this line:

:figwheel {:on-jsload "my-app.system/reset"}
This triggers the my-app.components.ui component to reset, which triggers the core namespace's (render) function to be called, in turn causing re-frame to dispatch the :initialize-db event. The issue is that this clears my entire app-db...say for example that I'm working on some complex workflow, I'm building up app state via the UI, make a code edit, and poof, the app state I've been building up vanishes on system reset. Is there a way around this? I could sync state to local storage via some kind of interceptor, but that seems heavy handed.

featheredtoast20:11:42

yeah, defonce is the way to go for persistent app state

featheredtoast20:11:40

it'd be nice to have a cljs system with the suspendable API to handle things like this, but that's only a wishlist item rn - there isn't anything I've seen that requires more than a defonce yet.