Debugging with debug

We will comment out the function call again to stop running this example. The debug operator will print out details about every event. We will just add it to the initial subscription, as follows:

func exampleWithPulish(){    let intervalSeq = Observable<Int>.interval(1, scheduler: MainScheduler.instance)    .publish()        intervalSeq        .debug()        .subscribe { print($0) }        delayInExecution(2) {        _ = intervalSeq.connect()    }        delayInExecution(4) {        _ = intervalSeq            .subscribe { print($0) }    }}exampleWithPulish()

Next, we will uncomment the function call and let the playground run this example. As you can see in the console logs, you will see much more information this time, as illustrated:

Note that it prints the subscription and then each ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.