I am injecting a model reference from a parent component to a child component. When the attributes of that model reference are changed, I need to update the child component's view.
This cannot be done using ngOnChanges because the reference to the model is not changed. This is by design and is mentioned in the Angular docs.
A suggested alternative is using ngDoCheck. This would allow me to see if any of the model reference's attributes have changed and call functions accordingly. However, the Angular docs mention that this will be costly due to the frequency that this lifecycle hook will be called.
Right now, the child component is subscribed to an observable from a service that updates all of my model references. When the service updates a model, it notifies subscribers that it is time to update their views.
The issue here is if I have at least two child components with different model references. With the current design, each time any model is updated, all child components will update their view.
This seems wasteful, but I'm not sure if utilizing ngDoCheck will be any better.
Should I be using ngDoCheck to update child components individually, or should I stick to using an observable that forces all child components to update when any model is updated?
If it is the former, what is some good documentation for ngDoCheck? The internet seems to surprisingly lack information on this lifecycle hook.