From 61a57142b0db097bbd859b189130c7b0b4ddb448 Mon Sep 17 00:00:00 2001 From: sdarbinyan Date: Fri, 24 Jul 2026 08:08:51 +0400 Subject: [PATCH] perf(app): add OnPush to root App component RC PERF-01 platform-wide performance audit. App was the only one of 191 @Component decorators still on default change detection; all state mutation flows through signal.set()/router-event handlers, so OnPush is safe (no direct DOM mutation, no non-signal mutable bindings read in the template). Audit findings (see report): - RxJS subscription leaks: 149 .subscribe() calls across 44 files reviewed; all either use takeUntilDestroyed, manual Subscription + ngOnDestroy, or self-completing HTTP/shareReplay observables in providedIn:'root' singletons. No leaks found, no changes needed. - OnPush coverage: 190/191 components already OnPush; app.ts fixed here. - @for/*ngFor tracking: 0 legacy *ngFor found; @for requires track at compile time in this Angular version. Already fully compliant. - Duplicate HTTP calls: CategoryFacade and ConfigService already use shareReplay({bufferSize:1, refCount:true}) caching consistently. - Signals/BehaviorSubject boilerplate: only 2 combineLatest usages app-wide, both narrow and already minimal; left as-is (no safe, isolated leaf case to convert without touching facade state shape). - Template method calls: mostly cheap signal reads or small pure per-item formatters; none warranted extraction given OnPush is already in place everywhere they're used. Co-Authored-By: Claude Sonnet 5 --- src/app/app.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/app.ts b/src/app/app.ts index 3150dc1..0710511 100644 --- a/src/app/app.ts +++ b/src/app/app.ts @@ -1,5 +1,5 @@ -import { Component, OnInit, signal, ApplicationRef, inject, DestroyRef } from '@angular/core'; +import { Component, OnInit, signal, ApplicationRef, inject, DestroyRef, ChangeDetectionStrategy } from '@angular/core'; import { Router, RouterOutlet, NavigationEnd } from '@angular/router'; import { Title } from '@angular/platform-browser'; import { HeaderComponent } from './components/header/header.component'; @@ -23,7 +23,8 @@ import { TelegramLoginComponent } from './components/telegram-login/telegram-log selector: 'app-root', imports: [RouterOutlet, HeaderComponent, FooterComponent, BackButtonComponent, TranslatePipe, FloatingNotificationsComponent, TelegramLoginComponent], templateUrl: './app.html', - styleUrl: './app.scss' + styleUrl: './app.scss', + changeDetection: ChangeDetectionStrategy.OnPush }) export class App implements OnInit { protected title = '';