Before starting, this link can be useful : what is the purpose of HMR ?.
I do not have a deep experience in huge projects management / conception. I'm still to young to have a beautiful beard. So I am here, looking for advices.
the seed
I am looking and thinking at this seed of angular 2 and I am wondering if using HMR is a viable option to develop a large application and how to do that.
Those are just thoughs, I just want to discuss with you to make my decision. We all need to cross our experiences :-)
data structure
Based on this example :
@Component({
selector: 'home',
templateUrl: `
<form (ngSubmit)="submitState(localState.value)" autocomplete="off">
<input
[value]="localState.value"
(input)="localState.value = $event.target.value"
placeholder="Submit Local State to App State">
<button>Submit Value</button>
</form>
`
})
export class HomeComponent {
localState = { value: '' };
constructor(public appState: AppState, public title: Title) {}
onSubmit(value: string) {
this.appState.set('value', value);
this.localState.value = '';
}
}
By using the appState, components can be dynamically reloaded and data can be injected. That sounds cool. But here is my first question : to enable this feature, components have to have a place in the appstate tree, so it's a good idea to use a localState
like in the example. This force us to play with an object inside our components, which can be huge. It can be annoying. Do you agree with that ? Can it be an issue on a large application ? (I'm going to work on a large app).
It can be nothing because I only have to store in my localStorage
data which I want to be tracked by HMR. So why not.
data storage
Speaking about storage, I am also using @ngrx/store as an implementation of Redux. It seems to be a really good idea because the state can be my localStorage
. When the app is updated, I just need to rehydrate my state and it works. Data in component will not be tracked by hmr, only the state will be.
Sounds great. But is it a good idea ? I've tried to find a connector to take care about communications between @ngrx/store and hmr. Victory ! but this package seems to be outdated.
I can do this by myself but is it a good idea ? Angular's services will use reducers and I can find hooks to update hmr's state.
I think that @ngrx/store and hmr are well kwnon by angular developpers. Those 2 technologies seems to fit well but I don't find a lot of ressources over here. So I'm thinking there must be an issue I don't see right now.
I wrote all of this to ask you advices about your experience with those technologies / problematics.
Do you see cons to combine those technologies ? I'm experimenting but I can't think about all the cases. That is why I need your help.
summary
- Is HMR ready for "production" ?
- Is it okay to move a lot of information inside @ngrx/store (things like 'this checkbox is checked', 'the current value of this input is
foobar
'...) - Most important : Do these technologies fit well ?
Those questions remind me https://github.com/CodeSequence/ngrx-store-hmr/issues/2.