Skip to content

Instantly share code, notes, and snippets.

@ardydedase
Created September 30, 2021 04:00
Show Gist options
  • Save ardydedase/da07f76c9608d178e4a7e02ef06a50ae to your computer and use it in GitHub Desktop.
Save ardydedase/da07f76c9608d178e4a7e02ef06a50ae to your computer and use it in GitHub Desktop.
this.results$ = this.searchSubject$.pipe(
debounceTime(200),
distinctUntilChanged(),
switchMap((searchString) => {
if ((searchString as any).replace(/\s/g, '')) {
switch (this.searchType) {
case SearchType.REPOS:
return this.githubService.searchRepos(searchString);
case SearchType.USERS:
return this.githubService.searchUsers(searchString);
default:
break;
}
}
})
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment