beeman / tutorial-angular-cli-hmr

Tutorial: Enable HRM in Angular CLI apps
https://medium.com/@beeman/1b0d13b80130
19 stars 3 forks source link

Is it possible to preserve state during hot reload? #4

Open niklas-dahl opened 7 years ago

niklas-dahl commented 7 years ago

this is great, but I thought hmr meant that the state of the application is preserved during the reload, is that possible?

I'am thinking that it could be possible to just re-initialize the component that changed and all its child components, but preserve state in the rest of the component tree.

niklas-dahl commented 7 years ago

I found https://github.com/beeman/tutorial-angular-cli-hmr/issues/2, but I'am using ngModel and still my state is not preseved.

peterkrieg commented 6 years ago

Not working for me either - anyone know if this can work? I attached a screenshot of a simple example of counter - when app.component.ts is changed, doesn't preserve state of counter.

Thanks for any help 👍

ezgif com-video-to-gif

PascalAOMS commented 6 years ago

In the terminal it says the following:

Hot Module Replacement (HMR) is enabled for the dev server.
  The project will still live reload when HMR is enabled,
  but to take advantage of HMR additional application code is required
  (not included in an Angular CLI project by default).
  See https://webpack.github.io/docs/hot-module-replacement.html
  for information on working with HMR for Webpack.

EDIT Run ng eject to edit the webpack config. It's a long file.

adrhc commented 6 years ago

@PascalAOMS What do you mean? What exactly should I do in order to preserve state?

Please add your response at https://stackoverflow.com/questions/49595833/how-to-preserve-state-during-hmr-using-angular.