PatrickJS / angular-hmr

:fire: Angular Hot Module Replacement for Hot Module Reloading

Home Page:https://patrickjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lazy loaded modules, reload only changed component

perrohunter opened this issue · comments

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?

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.

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

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