PatrickJS / angular-hmr

:fire: Angular Hot Module Replacement for Hot Module Reloading
https://patrickjs.com
Apache License 2.0
506 stars 45 forks source link

it will delete the DOM which are dynamic created? #36

Open wuzhouyang opened 7 years ago

wuzhouyang commented 7 years ago

In my project i use the Bootstrap, when i open a modal or open the dropdown buttons, i edit some css and save, then the modal will be hided,the dropdown buttons will be shrinked. And i create some DOM dynamically, similarly i edit some css then save,the DOM which i create was disappeared... i want to know the reason,thnx!!!

PatrickJS commented 7 years ago

hmr is destroying the angular app and bootstrapping the app again with the changes so if you're missing teardown logic in your components then there will be problems. same with not transferring state from one app to the next.

in this lifecycle hook hmrOnDestroy(store) you need to transfer state into the store during teardown to resume the state for the next app

in this lifecycle hook hmrOnInit(store) you will get state in the store from the previous app so this is where you would hydrate your app with it to when it bootstraps the app will look the same