Working with TS/Angular on a web application, I made the decision to refactor some code that handles displaying different overlays. Instead of having separate code for each overlay, I consolidated them into one "master overlay" and created a function within it to determine which settings should be used based on the specific variation needed. This function needs to check if any of the 20 variables that dictate whether an overlay should be shown have changed in order to display the correct overlay. To achieve this, I included all 20 variables as inputs in my component and implemented the function in ngOnChanges
. While I am aware that using ngOnChanges
can be risky due to running during every change detection cycle, I believe in this scenario I can control when it updates, ensuring it only does so when necessary. Do you think I am wrong for utilizing ngOnChanges
in this context?
Despite my team advising against using ngOnChanges
, I personally find it suitable for this particular situation.