Skip to content

Latest commit

 

History

History
74 lines (60 loc) · 2.62 KB

debounce.md

File metadata and controls

74 lines (60 loc) · 2.62 KB

Rx.Observable.prototype.debounce(dueTime, [scheduler])

Rx.Observable.prototype.throttleWithTimeout(dueTime, [scheduler])

Rx.Observable.prototype.throttle(dueTime, [scheduler]) DEPRECATED

Emits an item from the source Observable after a particular timespan has passed without the Observable omitting any other items.

Arguments

  1. dueTime (Number): Duration of the throttle period for each value (specified as an integer denoting milliseconds).
  2. [scheduler=Rx.Scheduler.timeout] (Any): Scheduler to run the throttle timers on. If not specified, the timeout scheduler is used.

Returns

(Observable): The throttled sequence.

Example

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

Location

File:

Dist:

Prerequisites:

NPM Packages:

NuGet Packages:

Unit Tests: