I'm working on an angular project, and I need to master change detection so as to make my project usable.
Here is a minimal repro : https://stackblitz.com/edit/angular-3py5bh
<div *ngIf="timeleft$ | async as timeleft"> //countdown (rxjs)
{{timeleft}}
</div>
<hello></hello> // simulated intensive function
So, basically, I have a main component with a countdown, that refreshes every 0.01s. In this component I have an embedded "hello" component, that includes (in real project) quite intense computations. I simulated these intense computations with a "slow function".
Problem : every time the countdown refreshes (so 100 times/second), the Hello component is refreshed as well, and the "slow function" is called...
As a result, the countdown display is broken (too slow) !!!
I know the answer relies on "change detection", but I'm too new to handle it well. That's why I'm asking for your help !
Thanks a lot !!! Serge