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

Lazy loaded modules, reload only changed component #49

Closed perrohunter closed 7 years ago

perrohunter commented 7 years ago

Hello, I'm loading my modules via lazy loading, however every time I change a component all the data in the service is lost, is there a way to avoid this?

digging through my code, my theory is that the services are getting re-initiated, I'm only declaring my service as a provider on my app.module.ts (top level module), is there a way to avoid the re-initialziation of the service?

crysislinux commented 7 years ago

Currently I don't think the way exist. angular-hmr will destroy the whole application and re render the whole app. it works different from react hot reloader.

one way to partially solve the problem is introducing something like ngrx/store. then re load the store with saved data when hot reload happens.

PatrickJS commented 7 years ago

what @crysislinux said is correct. We're recreating the app and if you want to persist data you need to use a store and inject it with the state from the previous app

stephengardner commented 6 years ago

@gdi2290 Has this been fixed or is there a tutorial on a way to make this store usage effective?