exhaustAll
Converts a higher-order Observable into a first-order Observable by dropping inner Observables while the previous inner Observable has not yet completed.
Flattens an Observable-of-Observables by dropping the next inner Observables while the current inner is still executing.
exhaustAll
subscribes to an Observable that emits Observables, also known as a
higher-order Observable. Each time it observes one of these emitted inner
Observables, the output Observable begins emitting the items emitted by that
inner Observable. So far, it behaves like mergeAll. However,
exhaustAll
ignores every new inner Observable if the previous Observable has
not yet completed. Once that one completes, it will accept and flatten the
next inner Observable and repeat this process.
Example
Run a finite timer for each click, only if there is no currently active timer
import { fromEvent, map, interval, take, exhaustAll } from 'rxjs';
const clicks = fromEvent(document, 'click');
const higherOrder = clicks.pipe(
map(() => interval(1000).pipe(take(5)))
);
const result = higherOrder.pipe(exhaustAll());
result.subscribe(x => console.log(x));