Use OnPush change detection strategy

master
Kevin C. Coram 2020-01-08 21:33:38 -05:00
parent b7870b607b
commit 8802b52e54
Signed by: kevin
GPG Key ID: 0342351B3D61AD35
4 changed files with 40 additions and 26 deletions

View File

@ -1,4 +1,9 @@
import { Component, Input, OnInit } from '@angular/core';
import {
ChangeDetectionStrategy,
Component,
Input,
OnInit,
} from '@angular/core';
import { FormArray } from '@angular/forms';
import { Address } from '@nested-forms/contact';
import { AddressComponent } from '../address/address.component';
@ -6,7 +11,8 @@ import { AddressComponent } from '../address/address.component';
@Component({
selector: 'nested-forms-address-list',
templateUrl: './address-list.component.html',
styleUrls: ['./address-list.component.css']
styleUrls: ['./address-list.component.css'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AddressListComponent implements OnInit {
@Input() addressArray: FormArray;
@ -25,7 +31,5 @@ export class AddressListComponent implements OnInit {
constructor() {}
ngOnInit() {
}
ngOnInit() {}
}

View File

@ -1,11 +1,17 @@
import { Component, OnInit, Input } from '@angular/core';
import { FormGroup, FormControl } from '@angular/forms';
import {
ChangeDetectionStrategy,
Component,
Input,
OnInit,
} from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { Address } from '@nested-forms/contact';
@Component({
selector: 'nested-forms-address',
templateUrl: './address.component.html',
styleUrls: ['./address.component.css']
styleUrls: ['./address.component.css'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AddressComponent implements OnInit {
@Input() addressGroup: FormGroup;
@ -22,7 +28,5 @@ export class AddressComponent implements OnInit {
constructor() {}
ngOnInit() {
}
ngOnInit() {}
}

View File

@ -1,17 +1,20 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import {
Contact,
ContactService,
} from '@nested-forms/contact';
ChangeDetectionStrategy,
Component,
OnDestroy,
OnInit,
} from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { Contact, ContactService } from '@nested-forms/contact';
import { Subscription } from 'rxjs';
import { NameComponent } from './name/name.component';
import { AddressListComponent } from './address-list/address-list.component';
import { NameComponent } from './name/name.component';
@Component({
selector: 'nested-forms-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AppComponent implements OnInit, OnDestroy {
contact: Contact;
@ -19,10 +22,7 @@ export class AppComponent implements OnInit, OnDestroy {
private subscription: Subscription;
constructor(
private service: ContactService,
private fb: FormBuilder,
) {}
constructor(private service: ContactService, private fb: FormBuilder) {}
public ngOnInit() {
this.subscription = this.service

View File

@ -1,11 +1,17 @@
import {
ChangeDetectionStrategy,
Component,
Input,
OnInit,
} from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { Component, OnInit, Input } from '@angular/core';
import { Name } from '@nested-forms/contact';
@Component({
selector: 'nested-forms-name',
templateUrl: './name.component.html',
styleUrls: ['./name.component.css']
styleUrls: ['./name.component.css'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class NameComponent implements OnInit {
@Input() nameGroup: FormGroup;