Step into Swift logo

What is the Scan Operator in RxSwift?

Scan Operator

RxSwift: Scan Operator

.scan { }

  • Applies a supplied predicate to the elements emitted by an Observable, sequentially, emitting each successful result.
  • Applies function to first element and then uses the result of this as the parameter for the second emitted elements applied function, and so on.
  • Acts like an accumulator.
  • Useful for for running totals, statistics, states…

scan((x, y) => x * y)


< All Posts