Skip to content

Commit 89fcd64

Browse files
committed
refactor: TT-18 Improve code to make it more readable
1 parent 6babc3e commit 89fcd64

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/app/modules/shared/components/technologies/technologies.component.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export class TechnologiesComponent implements OnInit, OnDestroy {
1818
readonly ALLOW_SEARCH = true;
1919
readonly MIN_SEARCH_TERM_LENGTH = 2;
2020
readonly TYPE_TO_SEARCH_TEXT = 'Please enter 2 or more characters';
21+
readonly WAITING_TIME_AFTER_KEY_UP = 400;
2122

2223
isLoading = false;
2324
technologies: string[];
@@ -43,16 +44,13 @@ export class TechnologiesComponent implements OnInit, OnDestroy {
4344
this.technologiesInputSubscription = this.technologiesInput$.pipe(
4445
filter(searchQuery => searchQuery && searchQuery.length >= this.MIN_SEARCH_TERM_LENGTH),
4546
distinctUntilChanged(),
46-
debounceTime(400)
47+
debounceTime(this.WAITING_TIME_AFTER_KEY_UP)
4748
).subscribe((searchQuery) => this.searchTechnologies(searchQuery));
4849

4950
this.technologiesSubscription = technologies$.subscribe(({ isLoading, technologyList }) => {
51+
const technologyItems = technologyList?.items;
5052
this.isLoading = isLoading;
51-
if ( technologyList.items ) {
52-
this.technologies = technologyList.items;
53-
} else {
54-
this.technologies = [];
55-
}
53+
this.technologies = technologyItems ? technologyItems : [];
5654
});
5755
}
5856

0 commit comments

Comments
 (0)