feat(ivy): support OnPush change detection (#22417)

PR Close #22417
This commit is contained in:
Kara Erickson
2018-02-23 13:17:20 -08:00
committed by Alex Eagle
parent e454c5a98e
commit 8c358844dd
11 changed files with 470 additions and 110 deletions

View File

@ -7,6 +7,7 @@
*/
import {SimpleChange} from '../change_detection/change_detection_util';
import {ChangeDetectionStrategy} from '../change_detection/constants';
import {PipeTransform} from '../change_detection/pipe_transform';
import {OnChanges, SimpleChanges} from '../metadata/lifecycle_hooks';
import {RendererType2} from '../render/api';
@ -55,7 +56,9 @@ export function defineComponent<T>(componentDefinition: ComponentDefArgs<T>): Co
afterContentChecked: type.prototype.ngAfterContentChecked || null,
afterViewInit: type.prototype.ngAfterViewInit || null,
afterViewChecked: type.prototype.ngAfterViewChecked || null,
onDestroy: type.prototype.ngOnDestroy || null
onDestroy: type.prototype.ngOnDestroy || null,
onPush: (componentDefinition as ComponentDefArgs<T>).changeDetection ===
ChangeDetectionStrategy.OnPush
};
const feature = componentDefinition.features;
feature && feature.forEach((fn) => fn(def));