I was inspired by a video on hotswapping JS files with React + Webpack for the web. I started trying it out with React + Backbone + RequireJS.
Seems to work, as long as I stick to the stateless parts of the code. I get really confused however, when I start thinking about what would happen if I swapped out some JS code that had Backbone Models or Collections, or some other data store representing state. I simply don't understand what would happen if a model file got swapped out - would things work and still reference the same objects in memory? Or could any small tweak completely break everything?
With stateless functional code, a small tweak doesn't matter, because the code is only transforming the data moving through it - the code is not retrieving data in memory?
How might swapping out .js files that represent state work? What are the limitations and when would it work?