NgRx and ChangeDetectionStrategy.OnPush

73 views
Skip to first unread message

Arnaud Deman

unread,
Apr 13, 2021, 9:53:57 AM4/13/21
to Angular and AngularJS discussion

Hello,

What would be the correct way to use ChangeDetectionStrategy.OnPush with a component that uses the ngrx store like in this example:
@Component ({
...
   changeDetection: ChangeDetectionStrategy.OnPush
})
export class MyComponent implements OnInit {
   render $: Observable <boolean>;
   (...)
   ngOnInit () {
     render $ = this._store.pipe (select (getRender));
   }
}


Should I use ChangeDetectorRef to manually refresh the component, use a wrapper component or something else?

Thanks,
Arnaud.

Arnaud Deman

unread,
Apr 13, 2021, 2:08:18 PM4/13/21
to Angular and AngularJS discussion
Hi,
In fact the async pipe works with the OnPush strategy.
Regards,
Arnaud.
Reply all
Reply to author
Forward
0 new messages