Skipping Irrelevant Requests

Let's see how we can increase our typeahead application's efficiency by skipping irrelevant requests using Rx operators like filter and distinctUntilChanged.

Now that the typeahead has debounceTime plugged in, far fewer requests are sent.

That said, a lot of requests are still being sent, so there’s work yet to do.

Filtering irrelevant requests

You have two more tricks up your sleeve to cut down on these superfluous requests. The first is filter (you’ll recall from Manipulating Streams), which you can use to remove items that won’t provide useful results.

filter operator

Requests of three or fewer characters aren’t likely to provide relevant information (a list of all the StackOverflow questions that include the letter a is terribly helpful), so filter allows searches only where the query has more than three characters:

Get hands-on with 1200+ tech skills courses.