What’s new in RxSwift 5

Learn about the newest additions to RxSwift

Relays are now a separate framework — RxRelay

On the left: RxSwift 4’s dependency graph. On the right: RxSwift 5’s dependency graph.

TimeInterval → DispatchTimeInterval

RxSwift 4.x:

RxSwift 4 uses TimeInterval

RxSwift 5.x:

RxSwift 5 uses DispatchTImeInterval

Variable is finally deprecated

RxSwift 4.x:

RxSwift 4.x has a soft-deprecation for Variable

RxSwift 5.x:

RxSwift 5.x completely deprecates Variable

Additional do(on:) overloads

RxSwift 4.x:

RxSwift 4.x provides do(onNext:onError:onCompleted:)

RxSwift 5.x:

RxSwift 5.x also has do(afterNext:afterError:afterCompleted:)

bind(to:) now supports multiple observers

RxSwift 4 only allows binding to a single observer at a time
RxSwift 5 allows binding to a variadic list of observers

A new compactMap operator

RxSwift 4.x:

Unwrapping optional streams is not built-in to RxSwift 4

RxSwift 5.x:

RxSwift 5.x provides compactMap to unwrap optional streams

toArray() now returns Single<T>

RxSwift 4.x:

toArray() returns an Observable<T> in RxSwift 4.x

RxSwift 5.x:

toArray() returns a Single<T> in RxSwift 5.x

Generic constraints naming overhaul

RxSwift 4.x:

Extending Observable in RxSwift 4 uses the E generic constraint

RxSwift 5.x:

Extending Observable in RxSwift 5 uses the Element generic constraint

Community Projects

Wrapping up

iOS Tech Lead @ Gett 🚕 RxSwift & RxSwiftCommunity core contributor. International speaker and worldwide hackathon winner. Fiddling with tech for a living. 🤓