Step into Swift logo

What is the Just Operator in RxSwift?

Just Operator

RxSwift: Just Operator

  • .just operator creates an observable sequence containing just a single element and a .completed event.
  • Type inference means we don’t need to define the type.
let lotteryNumberOne = 1
let lotteryNumberTwo = 2
let lotteryNumberThree = 3

let observable: Observable<Int> = Observable<Int>.just(lotteryNumberOne)
// Observable containing just lotteryNumberOne i.e. 1

< All Posts