Testing asynchronous code

Let's make use of a real-world example to start with—suppose you are driving down from location A to location B and along the way you want to track only the traffic lights and nothing else that is on the road; that is, you want to ignore any tolls or check posts, and so on, and focus only on the traffic lights. In other words, you want to filter out traffic lights from all the other things that you might encounter during your journey.

So how will we filter them out? The first concept that might come to your mind will be streams, since that's the concept that underpins Rx, and the second will be subscriptions. So, if you subscribe to those streams, you will be able to filter out those events. If you don't subscribe ...

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.