tomastrajan / angular-ngrx-material-starter

Angular, NgRx, Angular CLI & Angular Material Starter Project
https://tomastrajan.github.io/angular-ngrx-material-starter
MIT License
2.83k stars 917 forks source link

Using OnPush to improve performance #352

Closed simply10w closed 5 years ago

simply10w commented 6 years ago

Describe the feature you'd like:

Adding OnPush change detection to all components.

Since we already are utilizing @ngrx/store with rxjs streams and async pipe, we get markForCheck for free in most situations.

By adding on push, only some parts of the application would need to be checked when change detection runs. Currently it runs over the entire tree.

That way we would also enforce good practices from the get go, avoiding mutating state, and if mutation needs to happen, triggering change detection manually.

Other information:

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

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

timdeschryver commented 6 years ago

Great catch! I would say go for it 😄

simply10w commented 6 years ago

Great. I'll play around! 😄

tomastrajan commented 6 years ago

Also, if I remember correctly it should be possible to adjust configuration in angular.json so that all components generated using ng g c are automatically OnPush by default which would make sense in this case ;)

simply10w commented 6 years ago

You are right, there is. They have changed a little the way how it's done, now we need to point to the schematic for components, but that ability is still there.

I'll add that also.

Thanks for the tip. :D

timdeschryver commented 6 years ago

Looking forward to it!