Emits an item from the source Observable after a particular timespan has passed without the Observable omitting any other items.
dueTime
(Number
): Duration of the throttle period for each value (specified as an integer denoting milliseconds).[scheduler=Rx.Scheduler.timeout]
(Any
): Scheduler to run the throttle timers on. If not specified, the timeout scheduler is used.
(Observable
): The throttled sequence.
var times = [
{ value: 0, time: 100 },
{ value: 1, time: 600 },
{ value: 2, time: 400 },
{ value: 3, time: 700 },
{ value: 4, time: 200 }
];
// Delay each item by time and project value;
var source = Rx.Observable.from(times)
.flatMap(function (item) {
return Rx.Observable
.of(item.value)
.delay(item.time);
})
.debounce(500 /* ms */);
var subscription = source.subscribe(
function (x) {
console.log('Next: %s', x);
},
function (err) {
console.log('Error: %s', err);
},
function () {
console.log('Completed');
});
// => Next: 3
// => Completed
File:
Dist:
Prerequisites:
- If using
rx.time.js
NPM Packages:
NuGet Packages:
Unit Tests: