What is the difference between throttleTime vs debounceTime in rxjs and when to choose which? : <p>I'm trying to understand <code>throttleTime</code> vs <code>debounceTime</code> and which one is to be used when?</p>

<p>I have an upvote button  that makes an API request to the backend (which counts the votes). User can submit button multiple times, but I'd like to limit the times per second button can be pressed.</p>

<p>I know throttleTime and debounceTime operators can do that, but which should I choose better?</p>

<pre><code>const upvoteClicks = fromEvent(this.el.nativeElement, 'click')
 .pipe(debounceTime(500))
 .subscribe(() =&gt; this.myService.postUpvote(this.postId));

</code></pre>
