Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
refactor: TT-18 Improve code to make it more readable
  • Loading branch information
jcalarcon98 committed Aug 23, 2021
commit 89fcd648f8d44bfe8369d8470e8fbf0b14584b8b
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class TechnologiesComponent implements OnInit, OnDestroy {
readonly ALLOW_SEARCH = true;
readonly MIN_SEARCH_TERM_LENGTH = 2;
readonly TYPE_TO_SEARCH_TEXT = 'Please enter 2 or more characters';
readonly WAITING_TIME_AFTER_KEY_UP = 400;

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

this.technologiesSubscription = technologies$.subscribe(({ isLoading, technologyList }) => {
const technologyItems = technologyList?.items;
this.isLoading = isLoading;
if ( technologyList.items ) {
this.technologies = technologyList.items;
} else {
this.technologies = [];
}
this.technologies = technologyItems ? technologyItems : [];
});
}

Expand Down