O'Reilly logo

Reactive Programming with Swift 4 by Navdeep Singh

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The retry operator

The retry operator does not really handle the error. It just ignores it, and it will resubscribe to an Observable that emits an error. Let's start with the implementation. We will define a shouldEmitError that equals true, which we will use as a quick way to prevent our sequence subscription from retrying indefinitely in this example. Now we will create an Observable sequence of the Int type, as follows:

example(for: "retry") {    let disposeBag = DisposeBag()    var shouldEmitError = true        let observableSeq = Observable<Int>.create{ observer in            }}

We will add two next events to the observer, which will be emitted to the subscribers. This is another way to create an Observable sequence using create and manually building it up ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required