Skip to content

Commit 3931ad8

Browse files
vik-13mgechev
authored andcommitted
refactor: use onPush strategy
1 parent 430bb54 commit 3931ad8

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/app/app.component.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { KeyValue } from '@angular/common';
2727
styleUrls: ['./app.component.scss'],
2828
changeDetection: ChangeDetectionStrategy.OnPush
2929
})
30-
export class AppComponent implements OnDestroy {
30+
export class AppComponent implements AfterViewInit, OnDestroy {
3131
projectSet = false;
3232
loading = false;
3333
queryList: KeyValue<string, IdentifiedStaticSymbol>[] = [];
@@ -68,6 +68,23 @@ export class AppComponent implements OnDestroy {
6868
this._cd.markForCheck();
6969
});
7070

71+
this.maxWidth$ = fromEvent(window, 'resize').pipe(
72+
debounceTime(100),
73+
map(() => window.innerWidth),
74+
startWith(window.innerWidth)
75+
);
76+
77+
this._keyDownSubscription = fromEvent<KeyboardEvent>(document, 'keydown').pipe(
78+
filter((event: KeyboardEvent): boolean => !!(event.keyCode === BACKSPACE && this.quickAccess?.hidden)),
79+
tap({
80+
next: () => {
81+
this.prevState();
82+
}
83+
})
84+
).subscribe();
85+
}
86+
87+
ngAfterViewInit(): void {
7188
this._ipcBus.on(Message.ChangeTheme, (_: any, theme: string) => {
7289
this._ngZone.run(() => {
7390
this.theme = this.themes[theme];
@@ -90,21 +107,6 @@ export class AppComponent implements OnDestroy {
90107
});
91108
});
92109
});
93-
94-
this.maxWidth$ = fromEvent(window, 'resize').pipe(
95-
debounceTime(100),
96-
map(() => window.innerWidth),
97-
startWith(window.innerWidth)
98-
);
99-
100-
this._keyDownSubscription = fromEvent<KeyboardEvent>(document, 'keydown').pipe(
101-
filter((event: KeyboardEvent): boolean => !!(event.keyCode === BACKSPACE && this.quickAccess?.hidden)),
102-
tap({
103-
next: () => {
104-
this.prevState();
105-
}
106-
})
107-
).subscribe();
108110
}
109111

110112
ngOnDestroy(): void {

0 commit comments

Comments
 (0)