rxjs-exhaustmap-with-trailing
TypeScript icon, indicating that this package has built-in type declarations

2.1.1 • Public • Published

rxjs-exhaustmap-with-trailing

A variant of RxJS exhaustMap that includes trailing emissions from the source observable.

Marble Diagram

Just like the exhaustMap() RxJS operator, exhaustMapWithTrailing() will ignore all emissions from source observable as long as the projected observable is pending, but in addition it will include the last emission received from the source observable before the projected observable completed. Think of it as a combination of exhaustMap() and debounce().

Usage

import {exhaustMapWithTrailing} from "rxjs-exhaustmap-with-trailing"
import {delay} from "rxjs/operators"
import {fromEvent, of} from "rxjs"

const clicks = fromEvent(document, "click")

const result = clicks.pipe(
  exhaustMapWithTrailing((value) => of(value).pipe(delay(1000)))
)
result.subscribe((event) =>
  console.log("result: %d, %d", event.clientX, event.clientY)
)

Open CodeSandbox

API

exhaustMapWithTrailing

exhaustMapWithTrailing<T, R>(project: (value: T, index: number) => ObservableInput<R>): OperatorFunction<T, R>;

exhaustMapToWithTrailing

exhaustMapToWithTrailing<T, R>(innerObservable: Observable<R>): OperatorFunction<T, R>;

Credits

This is a packaged and unit tested version of the implementation posted by @aaronjensen here: https://github.com/ReactiveX/rxjs/issues/5004

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.1.1
    85,606
    • latest

Version History

Package Sidebar

Install

npm i rxjs-exhaustmap-with-trailing

Weekly Downloads

97,108

Version

2.1.1

License

MIT

Unpacked Size

21.8 kB

Total Files

14

Last publish

Collaborators

  • bjoerge