3

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?

3
  • 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
    Commented Aug 28, 2015 at 21:57
  • 1
    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
    Commented Oct 4, 2015 at 18:34
  • @lukewestby you might enjoy this even more :) medium.com/@the1mills/… Commented Oct 4, 2015 at 18:58

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.