matthiasn / systems-toolbox

Tools and building blocks for building Systems in Clojure and ClojureScript
Eclipse Public License 1.0
174 stars 23 forks source link

state is not preserved after a change to example GUI code #15

Closed batwicket closed 9 years ago

batwicket commented 9 years ago

Figwheel is now reacting to changes to the GUI cljs files, but when it does the GUI is completely refreshed and loses the previous state.

Working on it..

matthiasn commented 9 years ago

The approach with defonce works fine for the store component. I don't think it would work more generally as part of the library though. A type of component can currently be instantiated multiple times, but that wouldn't work with ´defonce´ as then state of the first one would also be the state for subsequent instantiations.

matthiasn commented 9 years ago

After using defonce as you suggested, I noticed that when editing UI components, the original state was shown until something triggered a state change. I adapted the library itself to now also publish initial states (possibly coming from defonce) so that UI would show that state after reload from Figwheel. You'll find that in the commit referenced above. Really useful idea, thanks.

matthiasn commented 9 years ago

I modified Birdwatch to leverage figwheel and it works amazingly well. The only thing I had to change was to define the client-side switchboard as a defonce and then wrap the messages to the switchboard in an init function as you suggested, plus add the loader namespace for development using Figwheel and live-reloading. As a result, the application loads on code changes while maintaining the live connection to the Twitter streaming API. Very nice. Thanks for this.