Step into Swift logo

What is the TakeUntil Operator in RxSwift?

TakeUntil Operator

RxSwift: TakeUntil Operator


  • Keep taking until some trigger observable emits an element.
  • Emit nothing after the trigger observable has emitted an element.
  • Can be used to dispose of a subscription instead of adding to a dispose bag.


let subject = PublishSubject<String>()
let trigger = PublishSubject<String>()

subject.takeUntil(tigger).subscribe(onNext: ....)

< All Posts