Testing in RxTest with ColdObservables

To show an example of working with a ColdObservable in RxTest, we will duplicate the previous example and change the name.

A ColdObservable in RxTest will only emit when there is a subscriber, and it will emit all its events to each subscriber on subscription. We will create two subscriptions in this example, so rather than using the subscription's dispose() property, we will use disposeBag this time. We will need two observers for this example, so we will duplicate the single one and then rename them as follows:

let disposeBag = DisposeBag()let firstObserver = scheduler.createObserver(Int.self)let secondObserver = scheduler.createObserver(Int.self)

Also, we will need two map Observables to test that ...

Get Reactive Programming with Swift 4 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.