RxJS skip debounce when using startWith

Viewed 1034

I have a stream that uses the startWith operator and debounceTime. I want the first value to skip the debounceTime and start immediately. How can I do it?

control.valueChanges
    .pipe(
      startWith(control.value), <=== this needs to skip debounce
      debounceTime(200),
      map(...),
    );
1 Answers

Just switch the order of operators and use startWith after debounceTime.

control.valueChanges.pipe(
  debounceTime(200),
  startWith(control.value),
  map(...),
);
Related