xgrommx / rx-book

xgrommx.github.io/rx-book
1.66k stars 186 forks source link

Throttle for keyup event stream #63

Open yiochen opened 8 years ago

yiochen commented 8 years ago

The example here uses throttle

var input = document.getElementById('input');
var dictionarySuggest = Rx.Observable.fromEvent(input, 'keyup')
  .map(() => input.value)
  .filter(text => !!text)
  .distinctUntilChanged()
  .throttle(250)
  .flatMapLatest(searchWikipedia)
  .subscribe(
    results => {
      list = [];
      list.concat(results.map(createItem));
    },
    err => logError(err)
  );

In my understanding, throttle will potentially ignore the last keyup event. Is this what we wanted? throttle