我偶然在
ngrx documentation中看到ChangeDetectionStrategy.它使用的是OnPush.
什么是Angular2中的ChangeDetectionStrategy,以及何时使用OnPush Vs Default?
如果对象是不可变的并且您没有更改组件中对象的状态,请使用OnPush策略.它将执行更好而不是默认,其中对象的每次更改都会使运行更改检测器解决更改.在
Change Detection Strategy: OnPush中描述了或多或少的类似
To inform Angular that we are going to comply with the conditions mentioned before to improve performance,we will use the
OnPush
change detection strategy
Angular的文档说
07001
OnPush
means that the change detector’s mode will be set toCheckOnce
during hydration.
Default
means that the change detector’s mode will be set toCheckAlways
during hydration.