BACK
ReferenceswitchScan
Reference · 106

switchScan

switchScan

rxjs.dev

An async scan that cancels the previous accumulator Observable.

Signature

switchScan(accumulator: (acc: R, value: T, index: number) => ObservableInput, seed: R): OperatorFunction

What it does

Like mergeScan, but when a new source value arrives, the previous accumulator Observable is cancelled.

When to use

State where only the latest computation matters: live-search state, recomputing filters, async reducers with cancellation.

See also

scan, mergeScan, switchMap

script.ts // TypeScript
CONSOLE · Console output
Hit Run to see the result...