Commit 61a5047e34a43a81322dfd4a9ec777980f544d98
1 parent
99f15f5f
UI: Performance improvements by using On Push change detection strategy on top level components
Showing
6 changed files
with
20 additions
and
12 deletions
@@ -14,13 +14,14 @@ | @@ -14,13 +14,14 @@ | ||
14 | /// limitations under the License. | 14 | /// limitations under the License. |
15 | /// | 15 | /// |
16 | 16 | ||
17 | -import { Component, Input, OnInit } from '@angular/core'; | 17 | +import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core'; |
18 | import { MenuSection } from '@core/services/menu.models'; | 18 | import { MenuSection } from '@core/services/menu.models'; |
19 | 19 | ||
20 | @Component({ | 20 | @Component({ |
21 | selector: 'tb-menu-link', | 21 | selector: 'tb-menu-link', |
22 | templateUrl: './menu-link.component.html', | 22 | templateUrl: './menu-link.component.html', |
23 | - styleUrls: ['./menu-link.component.scss'] | 23 | + styleUrls: ['./menu-link.component.scss'], |
24 | + changeDetection: ChangeDetectionStrategy.OnPush | ||
24 | }) | 25 | }) |
25 | export class MenuLinkComponent implements OnInit { | 26 | export class MenuLinkComponent implements OnInit { |
26 | 27 |
@@ -14,14 +14,15 @@ | @@ -14,14 +14,15 @@ | ||
14 | /// limitations under the License. | 14 | /// limitations under the License. |
15 | /// | 15 | /// |
16 | 16 | ||
17 | -import { Component, Input, OnInit } from '@angular/core'; | 17 | +import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core'; |
18 | import { MenuSection } from '@core/services/menu.models'; | 18 | import { MenuSection } from '@core/services/menu.models'; |
19 | import { Router } from '@angular/router'; | 19 | import { Router } from '@angular/router'; |
20 | 20 | ||
21 | @Component({ | 21 | @Component({ |
22 | selector: 'tb-menu-toggle', | 22 | selector: 'tb-menu-toggle', |
23 | templateUrl: './menu-toggle.component.html', | 23 | templateUrl: './menu-toggle.component.html', |
24 | - styleUrls: ['./menu-toggle.component.scss'] | 24 | + styleUrls: ['./menu-toggle.component.scss'], |
25 | + changeDetection: ChangeDetectionStrategy.OnPush | ||
25 | }) | 26 | }) |
26 | export class MenuToggleComponent implements OnInit { | 27 | export class MenuToggleComponent implements OnInit { |
27 | 28 |
@@ -14,14 +14,15 @@ | @@ -14,14 +14,15 @@ | ||
14 | /// limitations under the License. | 14 | /// limitations under the License. |
15 | /// | 15 | /// |
16 | 16 | ||
17 | -import { Component, OnInit } from '@angular/core'; | 17 | +import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; |
18 | import { MenuService } from '@core/services/menu.service'; | 18 | import { MenuService } from '@core/services/menu.service'; |
19 | import { MenuSection } from '@core/services/menu.models'; | 19 | import { MenuSection } from '@core/services/menu.models'; |
20 | 20 | ||
21 | @Component({ | 21 | @Component({ |
22 | selector: 'tb-side-menu', | 22 | selector: 'tb-side-menu', |
23 | templateUrl: './side-menu.component.html', | 23 | templateUrl: './side-menu.component.html', |
24 | - styleUrls: ['./side-menu.component.scss'] | 24 | + styleUrls: ['./side-menu.component.scss'], |
25 | + changeDetection: ChangeDetectionStrategy.OnPush | ||
25 | }) | 26 | }) |
26 | export class SideMenuComponent implements OnInit { | 27 | export class SideMenuComponent implements OnInit { |
27 | 28 |
@@ -14,7 +14,7 @@ | @@ -14,7 +14,7 @@ | ||
14 | /// limitations under the License. | 14 | /// limitations under the License. |
15 | /// | 15 | /// |
16 | 16 | ||
17 | -import { Component, OnInit } from '@angular/core'; | 17 | +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core'; |
18 | import { MenuService } from '@core/services/menu.service'; | 18 | import { MenuService } from '@core/services/menu.service'; |
19 | import { BreakpointObserver, BreakpointState } from '@angular/cdk/layout'; | 19 | import { BreakpointObserver, BreakpointState } from '@angular/cdk/layout'; |
20 | import { MediaBreakpoints } from '@shared/models/constants'; | 20 | import { MediaBreakpoints } from '@shared/models/constants'; |
@@ -25,7 +25,8 @@ import { HomeDashboard } from '@shared/models/dashboard.models'; | @@ -25,7 +25,8 @@ import { HomeDashboard } from '@shared/models/dashboard.models'; | ||
25 | @Component({ | 25 | @Component({ |
26 | selector: 'tb-home-links', | 26 | selector: 'tb-home-links', |
27 | templateUrl: './home-links.component.html', | 27 | templateUrl: './home-links.component.html', |
28 | - styleUrls: ['./home-links.component.scss'] | 28 | + styleUrls: ['./home-links.component.scss'], |
29 | + changeDetection: ChangeDetectionStrategy.OnPush | ||
29 | }) | 30 | }) |
30 | export class HomeLinksComponent implements OnInit { | 31 | export class HomeLinksComponent implements OnInit { |
31 | 32 | ||
@@ -37,6 +38,7 @@ export class HomeLinksComponent implements OnInit { | @@ -37,6 +38,7 @@ export class HomeLinksComponent implements OnInit { | ||
37 | 38 | ||
38 | constructor(private menuService: MenuService, | 39 | constructor(private menuService: MenuService, |
39 | public breakpointObserver: BreakpointObserver, | 40 | public breakpointObserver: BreakpointObserver, |
41 | + private cd: ChangeDetectorRef, | ||
40 | private route: ActivatedRoute) { | 42 | private route: ActivatedRoute) { |
41 | } | 43 | } |
42 | 44 | ||
@@ -57,6 +59,7 @@ export class HomeLinksComponent implements OnInit { | @@ -57,6 +59,7 @@ export class HomeLinksComponent implements OnInit { | ||
57 | if (this.breakpointObserver.isMatched(MediaBreakpoints['gt-lg'])) { | 59 | if (this.breakpointObserver.isMatched(MediaBreakpoints['gt-lg'])) { |
58 | this.cols = 4; | 60 | this.cols = 4; |
59 | } | 61 | } |
62 | + this.cd.detectChanges(); | ||
60 | } | 63 | } |
61 | 64 | ||
62 | sectionColspan(section: HomeSection): number { | 65 | sectionColspan(section: HomeSection): number { |
@@ -14,7 +14,7 @@ | @@ -14,7 +14,7 @@ | ||
14 | /// limitations under the License. | 14 | /// limitations under the License. |
15 | /// | 15 | /// |
16 | 16 | ||
17 | -import { Component, Input, OnDestroy, OnInit } from '@angular/core'; | 17 | +import { ChangeDetectionStrategy, Component, Input, OnDestroy, OnInit } from '@angular/core'; |
18 | import { BehaviorSubject, Subject } from 'rxjs'; | 18 | import { BehaviorSubject, Subject } from 'rxjs'; |
19 | import { BreadCrumb, BreadCrumbConfig } from './breadcrumb'; | 19 | import { BreadCrumb, BreadCrumbConfig } from './breadcrumb'; |
20 | import { ActivatedRoute, ActivatedRouteSnapshot, NavigationEnd, Router } from '@angular/router'; | 20 | import { ActivatedRoute, ActivatedRouteSnapshot, NavigationEnd, Router } from '@angular/router'; |
@@ -25,7 +25,8 @@ import { guid } from '@core/utils'; | @@ -25,7 +25,8 @@ import { guid } from '@core/utils'; | ||
25 | @Component({ | 25 | @Component({ |
26 | selector: 'tb-breadcrumb', | 26 | selector: 'tb-breadcrumb', |
27 | templateUrl: './breadcrumb.component.html', | 27 | templateUrl: './breadcrumb.component.html', |
28 | - styleUrls: ['./breadcrumb.component.scss'] | 28 | + styleUrls: ['./breadcrumb.component.scss'], |
29 | + changeDetection: ChangeDetectionStrategy.OnPush | ||
29 | }) | 30 | }) |
30 | export class BreadcrumbComponent implements OnInit, OnDestroy { | 31 | export class BreadcrumbComponent implements OnInit, OnDestroy { |
31 | 32 |
@@ -14,7 +14,7 @@ | @@ -14,7 +14,7 @@ | ||
14 | /// limitations under the License. | 14 | /// limitations under the License. |
15 | /// | 15 | /// |
16 | 16 | ||
17 | -import { Component, Input, OnDestroy, OnInit } from '@angular/core'; | 17 | +import { ChangeDetectionStrategy, Component, Input, OnDestroy, OnInit } from '@angular/core'; |
18 | import { User } from '@shared/models/user.model'; | 18 | import { User } from '@shared/models/user.model'; |
19 | import { Authority } from '@shared/models/authority.enum'; | 19 | import { Authority } from '@shared/models/authority.enum'; |
20 | import { select, Store } from '@ngrx/store'; | 20 | import { select, Store } from '@ngrx/store'; |
@@ -27,7 +27,8 @@ import { Router } from '@angular/router'; | @@ -27,7 +27,8 @@ import { Router } from '@angular/router'; | ||
27 | @Component({ | 27 | @Component({ |
28 | selector: 'tb-user-menu', | 28 | selector: 'tb-user-menu', |
29 | templateUrl: './user-menu.component.html', | 29 | templateUrl: './user-menu.component.html', |
30 | - styleUrls: ['./user-menu.component.scss'] | 30 | + styleUrls: ['./user-menu.component.scss'], |
31 | + changeDetection: ChangeDetectionStrategy.OnPush | ||
31 | }) | 32 | }) |
32 | export class UserMenuComponent implements OnInit, OnDestroy { | 33 | export class UserMenuComponent implements OnInit, OnDestroy { |
33 | 34 |