PatrickJS / NG6-todomvc-starter

Basic example of TodoMVC application written with angular and with use of components
https://angularclass.github.io/NG6-todomvc-starter/
MIT License
136 stars 73 forks source link

HMR Question #8

Closed ElliotPsyIT closed 8 years ago

ElliotPsyIT commented 8 years ago

Excuse the newbie question. I'm new to transpiling and bundling angular with webpack/ES6. I cloned and ran the project with no problems. But, I'm a bit puzzled about how Hot Module Reload works.

After entering a todo in the running app, I simply changed the title 'todos' to 'my todo' in app.component.js. I thought the title would update but the state of the app would be preserved. Instead the page fully reloaded and the app state was lost. Perhaps I have a naive understanding of the HMR system. Could I trouble you to briefly explain? Sorry this is a general question and not NG6 starter specific.

And thanks very much for this todoMVC app example of the NG6 starter. Great stuff!!

fesor commented 8 years ago

Hi, @ElliotPsyIT

As you maybe know, HMR is working by replacing modules. But if your framework (in our case it is Angular) doesn't allows you to replace components in runtime, you can't use HMR for it.

There was several attempts to make it possible by monkey-patching angular's modules system, but I don't know is anything working exists.

So currently HMR is used only to update styles.

ElliotPsyIT commented 8 years ago

Very good of you to take the time to answer. Much appreciated. And thanks again for the great NG6 starter!!