Reputation: 1314
I'm implementing some search and filtering controls with Angular. I've started using RxJs for this. First I had really bad time trying to understand operators like switchMap
and exauhstMap
, so I referred to this video and this article. Now I have better understanding of it. But a question popped up on my mind regarding using debounceTime()
with switchMap()
. Is it a common practice? Why do I need a debounceTime when switchMap will make sure to cancel all previous requests?
So if I'm implementing a search box like Google's, would I need to use both?
Upvotes: 0
Views: 988
Reputation: 1250
The point of using debounceTime
is to spare your back-end. If you send a request it doesn't matter for the BE if the response is got and handled be the FE. The request is there and it has to be handled by the BE.
In the search and filter functionality you know that you don't need to do anything while the user is typing (search functionality). So that's why you use debounceTime
Upvotes: 3