2

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?

  • 2
    Asking for links to resources on other sites is off-topic here, so I edited out that part of your question. Also, while I think this question is potentially very interesting, it is a bit broad in its current form. Are there any specific problems you're hoping to solve using this technique? – Ixrec Aug 28 '15 at 21:57
  • I highly recommend looking at the work Dan Abramov has done on React Hot Loader for Webpack. It's able to reload a React component with new code while still maintaining it's state. github.com/gaearon/react-hot-loader – lukewestby Oct 4 '15 at 18:34
  • @lukewestby you might enjoy this even more :) medium.com/@the1mills/… – Alexander Mills Oct 4 '15 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.