Skip to content

Commit 04a0c51

Browse files
committed
switch to onpush change detection
1 parent 0ad6eea commit 04a0c51

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

src/app/app.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { Component, inject, OnInit } from '@angular/core';
1+
import {
2+
ChangeDetectionStrategy,
3+
Component,
4+
inject,
5+
OnInit,
6+
} from '@angular/core';
27

38
import { MazeComponent } from './maze/maze.component';
49
import { GameStateService } from './game-state.service';
@@ -14,6 +19,7 @@ const DARK_MODE_CLASS = 'dark-mode';
1419
imports: [LogoComponent, MazeComponent],
1520
templateUrl: './app.component.html',
1621
styleUrl: './app.component.scss',
22+
changeDetection: ChangeDetectionStrategy.OnPush,
1723
})
1824
export class AppComponent implements OnInit {
1925
readonly gameStateService = inject(GameStateService);

src/app/logo/logo.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, Input } from '@angular/core';
1+
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
22

33
@Component({
44
selector: 'amaze-logo',
@@ -301,6 +301,7 @@ import { Component, Input } from '@angular/core';
301301
}
302302
`,
303303
],
304+
changeDetection: ChangeDetectionStrategy.OnPush,
304305
host: {
305306
'[style.height]': "sizePx + 'px'",
306307
},

src/app/maze/maze.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
AfterViewInit,
3+
ChangeDetectionStrategy,
34
Component,
45
ElementRef,
56
inject,
@@ -18,6 +19,7 @@ import { Dir, Maze, type Node } from '../../lib';
1819
imports: [NodeComponent],
1920
templateUrl: './maze.component.html',
2021
styleUrl: './maze.component.scss',
22+
changeDetection: ChangeDetectionStrategy.OnPush,
2123
host: {
2224
'[attr.tabindex]': '0',
2325
},

src/app/node/node.component.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { Component, computed, inject, input } from '@angular/core';
1+
import {
2+
ChangeDetectionStrategy,
3+
Component,
4+
computed,
5+
inject,
6+
input,
7+
} from '@angular/core';
28
import { corrupt } from 'exhaustive';
39

410
import { type Node, Dir, ALL_DIRS } from '../../lib';
@@ -18,6 +24,7 @@ import { GameStateService } from '../game-state.service';
1824
}
1925
`,
2026
styleUrl: './node.component.scss',
27+
changeDetection: ChangeDetectionStrategy.OnPush,
2128
host: {
2229
'[class]': 'classes()',
2330
'[class.material-symbols]': 'true',

0 commit comments

Comments
 (0)