angular-hmr icon indicating copy to clipboard operation
angular-hmr copied to clipboard

it will delete the DOM which are dynamic created?

Open wuzhouyang opened this issue 8 years ago • 1 comments

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!!!

wuzhouyang avatar Nov 07 '16 06:11 wuzhouyang

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

PatrickJS avatar Nov 30 '16 15:11 PatrickJS