Skip to content

Commit 35192de

Browse files
committed
Merge branch 'eneajaho-simplify-angular'
2 parents 615c4a8 + 517548c commit 35192de

File tree

11 files changed

+115
-115
lines changed

11 files changed

+115
-115
lines changed

frameworks/keyed/angular-nozone/angular.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"prefix": "app",
2525
"architect": {
2626
"build": {
27-
"builder": "@angular-devkit/build-angular:browser",
27+
"builder": "@angular-devkit/build-angular:browser-esbuild",
2828
"options": {
2929
"outputPath": "dist/angular",
3030
"index": "src/index.html",

frameworks/keyed/angular-nozone/src/app/app.component.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { NgFor } from '@angular/common';
2-
import { ChangeDetectorRef, Component, VERSION } from '@angular/core';
2+
import { ChangeDetectorRef, Component, VERSION, inject } from '@angular/core';
33

44
interface Data {
55
id: number;
@@ -13,15 +13,13 @@ interface Data {
1313
templateUrl: './app.component.html',
1414
})
1515
export class AppComponent {
16+
private cdr = inject(ChangeDetectorRef);
17+
1618
data: Array<Data> = [];
1719
selected?: number = undefined;
1820
id: number = 1;
1921
backup?: Array<Data> = undefined;
20-
version: string;
21-
22-
constructor(private changeDetectorRef: ChangeDetectorRef) {
23-
this.version = VERSION.full;
24-
}
22+
version = VERSION.full;
2523

2624
buildData(count: number = 1000): Array<Data> {
2725
var adjectives = ["pretty", "large", "big", "small", "tall", "short", "long", "handsome", "plain", "quaint", "clean", "elegant", "easy", "angry", "crazy", "helpful", "mushy", "odd", "unsightly", "adorable", "important", "inexpensive", "cheap", "expensive", "fancy"];
@@ -46,7 +44,7 @@ export class AppComponent {
4644
select(item: Data, event: Event) {
4745
event.preventDefault();
4846
this.selected = item.id;
49-
this.changeDetectorRef.detectChanges();
47+
this.cdr.detectChanges();
5048
}
5149

5250
delete(item: Data, event: Event) {
@@ -57,41 +55,41 @@ export class AppComponent {
5755
break;
5856
}
5957
}
60-
this.changeDetectorRef.detectChanges();
58+
this.cdr.detectChanges();
6159
}
6260

6361
run() {
6462
this.data = this.buildData();
65-
this.changeDetectorRef.detectChanges();
63+
this.cdr.detectChanges();
6664
}
6765

6866
add() {
6967
this.data = this.data.concat(this.buildData(1000));
70-
this.changeDetectorRef.detectChanges();
68+
this.cdr.detectChanges();
7169
}
7270

7371
update() {
7472
for (let i = 0; i < this.data.length; i += 10) {
7573
this.data[i].label += ' !!!';
7674
}
77-
this.changeDetectorRef.detectChanges();
75+
this.cdr.detectChanges();
7876
}
7977
runLots() {
8078
this.data = this.buildData(10000);
8179
this.selected = undefined;
82-
this.changeDetectorRef.detectChanges();
80+
this.cdr.detectChanges();
8381
}
8482
clear() {
8583
this.data = [];
8684
this.selected = undefined;
87-
this.changeDetectorRef.detectChanges();
85+
this.cdr.detectChanges();
8886
}
8987
swapRows() {
9088
if (this.data.length > 998) {
9189
var a = this.data[1];
9290
this.data[1] = this.data[998];
9391
this.data[998] = a;
9492
}
95-
this.changeDetectorRef.detectChanges();
93+
this.cdr.detectChanges();
9694
}
9795
}

frameworks/keyed/angular-nozone/src/app/app.config.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { bootstrapApplication } from '@angular/platform-browser';
22
import { AppComponent } from './app/app.component';
3-
import { appConfig } from './app/app.config';
3+
import { NgZone, ɵNoopNgZone } from '@angular/core';
44

5-
bootstrapApplication(AppComponent, appConfig)
6-
.catch((err) => console.error(err));
5+
bootstrapApplication(AppComponent, {
6+
providers: [
7+
// https://github.com/angular/angular/issues/47538
8+
{ provide: NgZone, useClass: ɵNoopNgZone }
9+
]
10+
});

frameworks/keyed/angular/angular.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"prefix": "app",
2525
"architect": {
2626
"build": {
27-
"builder": "@angular-devkit/build-angular:browser",
27+
"builder": "@angular-devkit/build-angular:browser-esbuild",
2828
"options": {
2929
"outputPath": "dist/angular",
3030
"index": "src/index.html",

frameworks/keyed/angular/src/app/app.component.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ export class AppComponent {
1717
selected?: number = undefined;
1818
id: number = 1;
1919
backup?: Array<Data> = undefined;
20-
version: string;
21-
22-
constructor() {
23-
this.version = VERSION.full;
24-
}
20+
version = VERSION.full;
2521

2622
buildData(count: number = 1000): Array<Data> {
2723
var adjectives = ["pretty", "large", "big", "small", "tall", "short", "long", "handsome", "plain", "quaint", "clean", "elegant", "easy", "angry", "crazy", "helpful", "mushy", "odd", "unsightly", "adorable", "important", "inexpensive", "cheap", "expensive", "fancy"];

frameworks/keyed/angular/src/app/app.config.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

frameworks/keyed/angular/src/main.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import { bootstrapApplication } from '@angular/platform-browser';
22
import { AppComponent } from './app/app.component';
3-
import { appConfig } from './app/app.config';
43

5-
bootstrapApplication(AppComponent, appConfig)
6-
.catch((err) => console.error(err));
4+
bootstrapApplication(AppComponent);

0 commit comments

Comments
 (0)