platform icon indicating copy to clipboard operation
platform copied to clipboard

Hot Module Replacement causes duplicate instances of Application Stores

Open markgoho opened this issue 4 years ago • 1 comments

Minimal reproduction of the bug/regression with instructions:

Use NgRx Store DevTools and turn on HMR in Angular

Expected behavior:

HMR does not create a new instance of the entire NgRx store

Versions of NgRx, Angular, Node, affected browser(s) and operating system(s):

NgRx 10.0.1 Angular 11.0.3 Node 12.18.3 OS win32 x64 Chrome 90.0.4400.0

Other information:

Here's a nice way of visualizing the NgRx stores after a few HMR cycles in local development. image

@MikeRyanDev said in https://github.com/ngrx/platform/issues/625

We don't plan on supporting HMR directly in NgRx. It is not one of the goals of the library and it is hard to imagine how we could make it work well with things like Effects.

However, this was nearly three years ago and now that HMR is officially a part of Angular, I wonder if we'd consider officially supporting HMR. If not, that's okay, this issue can serve as a more recent record of the decision.

I would be willing to submit a PR to fix this issue

[ ] Yes (Assistance is provided if you need help submitting a pull request) [X] No

markgoho avatar Jan 27 '21 14:01 markgoho

I'll be taking a look at this soon to improve the cleanup of instances when used with HMR

brandonroberts avatar Aug 12 '22 12:08 brandonroberts