Does async pipe trigger onPush change detection in angular?

72 Views Asked by At

I've checked multiple places for above question but found conflicting answers. For example in angular university it says that change detection gets triggered when async pipe gets a new observable value. But I found on multiple medium articles that say that it marks for check only. Async pipe code reference also seems to support that.

Can someone tell what does actually happen in this case? Thanks in advance.

1

There are 1 best solutions below

0
Matthieu Riegler On

The a zonefull application, the AsyncPipe will only mark a component as dirty (via calling markForCheck).

markForCheck doesn't not trigger a change detection per se but OnPush component are only change detected when they are dirty.

What often happens is that the AsyncPipe is triggered somehow/somewhere by a Promise resolving (a HTTP call) or a user action. Both of those do trigger a change detection.

So in a sense yes the AsyncPipe will trigger a change detection, but not directly.