BACK
ReferencethrottleTime
Reference · 18

throttleTime

throttleTime

rxjs.dev

Emits at most one value per interval.

Signature

throttleTime(duration: number, scheduler?, config?): MonoTypeOperatorFunction

Marble diagram

in:           a-b-c--d-e-|
throttle(20):  a------d---|

What it does

After letting the first value through, it "closes the gate" for duration milliseconds. By default it emits the leading value (the first) but not the trailing one (the last); this is configurable via config.

When to use

Anti-flood for scroll, mousemove, key presses. When a steady reaction rate matters more than "waiting for silence".

See also

debounceTime, auditTime, sampleTime

script.ts // TypeScript
CONSOLE · Console output
Hit Run to see the result...