Step into Swift logo

What is the Sample Operator in RxSwift?

Sample Operator

RxSwift: Sample Operator

.sample()

  • Emits the most recent element emitted by an Observable within a periodic time interval.
  • Similar to withLatestFrom, however sample takes a trigger Observable as a parameter.
  • When the tigger Observable ends, the most recent element from the source Observable will emit.
--1--------2---3----4--------5------>
------a-----b-c-------------d----|--->

sample

------1-----2---------------4----5-->

< All Posts