RxJS challenge #8: smart search operator function

Roman Sedov
AngularWave

--

In my new challenge you are offered to make an RxJS operator function that prevents unnecessary backend requests when it is possible to calculate items locally.

Try to solve it here:

https://stackblitz.com/edit/rxjs-challenge-8

My solution

So, there are many good solutions in replies to my tweet with the challenge, take a look:

You can compare them and choose a one you like. In all those solutions people make cache for all requests. And I decided to solve the task a bit differently. I will write an operator that caches results for a narrowed search.

For example, we type tes and get ['test1', 'test2', 'test3'] . Now we can continue typing test and all we can get is the same result or fewer (for this case the same). This means we can filter data that we have already got on the client-side.

Let’s write such a solution:

--

--