Comments (3)
As the ProductEditComponent currently stands, it can't be OnPush because of the way it handles the validation messages. Those are done with direct assignments. Specifically displayMessage
.
The validation would need to be modified before it could support OnPush change detection.
from angular-ngrx-gettingstarted.
@DeborahK ok, thx, if I add markForCheck( )
before
https://github.com/DeborahK/Angular-NgRx-GettingStarted/blob/master/APM-Demo5/src/app/products/product-edit/product-edit.component.ts#L69
can it support OnPush ?
btw, as far as I remember, you mentioned something like reducer replaces the whole exiting state and generates a new state instead of mutating the state thus to keep it immutable .
but for the https://github.com/DeborahK/Angular-NgRx-GettingStarted/blob/master/APM-Demo5/src/app/products/state/product.reducer.ts ,
the state
here is the ProductState which is part of the AppState.
if AppState is the big object, the ProductState is a property of this big object, your reducer here is just replacing the ProductState property here and not replacing other direct property of the big object. Thus it is not replacing the whole state, instead, it just changes part of it and that is kind of mutating the object , which violates the immutability principle. please correct me if I am wrong.
from angular-ngrx-gettingstarted.
@bakkiung the NgRx library manages the aggregated state and state history for you so you do not need to say update my slice of state and then now update the whole state tree. The library will handle making a new copy of state and also the history of the previous state. This is a cool article describing reducers and scans in RxJS that describe how these work in relation to NgRx you might like https://gist.github.com/btroncone/a6e4347326749f938510#whats-a-reducer.
In many of the large NgRx apps you inevitable have places where you need to use ChangeDetectorRef.markForCheck()
but best to use it pragmatically and look for a way to refactor and avoid it. In this case you can try adding ChangeDetectorRef.markForCheck()
but sometimes if the component is working in a less reactive way or you are refactoring an existing app to use NgRx it might be better to leave off onPush and likely you will not be able to see a performance difference.
from angular-ngrx-gettingstarted.
Related Issues (20)
- Add NgRx tests HOT 2
- Errors after upgrading to Angular 8 HOT 3
- CSS is missing HOT 3
- Store Undefined?
- Can you please convert to the use of action, reducer and effect creaters HOT 4
- Suggestion for a product list with server-side sorting, paging and search HOT 2
- Angular 9 HOT 5
- On delete, check current product id matches deleted product HOT 1
- APM-Demo5 npm install fails HOT 2
- Minor bug on adding products when all removed - APM-0, APM-1, APM-2 HOT 2
- npm install fails - ERESOLVE unable to resolve dependency tree HOT 3
- How to bring product-edit on Modal HOT 1
- Review - Do we need the if block before subscribing to the products state in 'Subscribing to the Store to Get State Changes'
- Module 10, check video suggestion to add the OnChanges lifecycle hook to the ProductListComponent
- After installing npm the project is not running and getting the error
- Remove references to 'cycles' in redux module when discussing what not to put in the store.
- Toggle password not working? HOT 2
- ngrx/store not getting installed HOT 3
- Node version compatibility issues <= 14.17.5 required HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-ngrx-gettingstarted.