I am very undecided whether to use BehaviorSubject to bind data to html. Below are two examples, the First sample binds normally, and the second one binds with "changeDetection: ChangeDetectionStrategy.OnPush" and "BehaviorSubject"
https://stackblitz.com/edit/angular-ivy-gbfqjo?file=src/app/app.component.ts
https://stackblitz.com/edit/angular-ivy-jgnqpt?file=src/app/app.component.ts
As seen in Console , The first method, (ChangeDetection is default and always running), it always calls setName function and logs "init", but in second method, setName is only calls when if $data is registered new value, because of "ChangeDetectionStrategy.OnPush" (dont need ChangeDetectorRef.detectChanges() because data$ already inited).
When should I use method 1 or method 2? Is there an important performance increase?
For example, which method should I use to show 100 data on the table (can be delete from table)?
Which one should I use to lazy load messages (like an infinite scroll)?
When should I use the BehaviorSubject (when just I need Observable) or should I always use it to bind data?