Emit first value then ignore for specified duration
Examples
Example 1: Emit first value, ignore for 5s window
( )
// RxJS v6+
import { interval } from 'rxjs';
import { throttleTime } from 'rxjs/operators';
// emit value every 1 second
const source = interval(1000);
/*
emit the first value, then ignore for 5 seconds. repeat...
*/
const example = source.pipe(throttleTime(5000));
// output: 0...6...12
const subscribe = example.subscribe(val => console.log(val));
Example 2: Emit on trailing edge using config
// RxJS v6+
import { interval, asyncScheduler } from 'rxjs';
import { throttleTime } from 'rxjs/operators';
const source = interval(1000);
/*
emit the first value, then ignore for 5 seconds. repeat...
*/
const example = source.pipe(throttleTime(
5000,
asyncScheduler,
{ trailing: true }
));
// output: 5...11...17
const subscribe = example.subscribe(val => console.log(val));