Search code examples
javascriptangularangular2-changedetection

angular onpush component rerenders only with async pipe inside template


I have my component with ChangeDetectionStrategy.OnPush strategy.

Im passing data from parent via async pipe, when that data change component refuse to rerender.

When im instead of using async pipe in parent pass obvservable and use async pipe inside of child template, rerenders are called correctly.

Anyone knows why that happens (angular v9)? I guess it have something to do with zone.js triggering change detection but why where how? I have no clue :(


Solution

  • Thats why

    https://github.com/angular/angular/blob/master/packages/common/src/pipes/async_pipe.ts#L146

    using async pipe rerenders view.