1
0
Fork 0

Use OnPush change detection strategy

master
Kevin C. Coram 2020-01-08 21:33:38 -05:00
commit 8802b52e54
Assinado por: kevin
ID da chave GPG: 0342351B3D61AD35
4 arquivos alterados com 40 adições e 26 exclusões

Ver arquivo

@ -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;
@ -23,9 +29,7 @@ export class AddressListComponent implements OnInit {
return list;
}
constructor() { }
ngOnInit() {
}
constructor() {}
ngOnInit() {}
}

Ver arquivo

@ -1,15 +1,21 @@
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;
static buildForm(addr: Address): FormGroup {
return new FormGroup({
line1: new FormControl(addr ? addr.line1 : ''),
@ -20,9 +26,7 @@ export class AddressComponent implements OnInit {
});
}
constructor() { }
ngOnInit() {
}
constructor() {}
ngOnInit() {}
}

Ver arquivo

@ -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

Ver arquivo

@ -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;