Book Image

Reactive Programming with Swift

By : Cecil Costa
Book Image

Reactive Programming with Swift

By: Cecil Costa

Overview of this book

<p><span id="description" class="sugar_field">Reactive programming helps you write applications that are more powerful and efficient. You can write more software, help more people, and create applications that scale. Reactive programming is a growing paradigm that we will help you set to work in Swift.</span></p> <p><span class="sugar_field"><span id="description" class="sugar_field"> Reactive Programming with Swift guides you through migrating from the traditional way of developing to the new ReactiveCocoa framework, which uses Swift as its main programming language. You will learn how to develop with this framework, debug code, create unit tests, use additional frameworks, and convert a traditional framework into a ReactiveCocoa one.</span></span></p> <p><span class="sugar_field"><span id="description" class="sugar_field"><span id="description" class="sugar_field"> Starting with a crash course on the fundamental concepts of Reactive programming, we’ll set you up so you’re ready to create reactive applications. We’ll then move on to topics such as Graphical events, Streaming, and Core data, which will help you dive deeper with advanced programming. The concept of switching your programming concepts from imperative to functional reactive programming will also be covered. By the end of this book, you will be able to successfully create highly functional apps using Swift.</span> </span></span></p>
Table of Contents (14 chapters)
Reactive Programming with Swift
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface

Waiting for 10 seconds


As mentioned before, the reverse geocoder will be updated every 10 seconds. We can do this using the NSTimer signal that we have completed. However, let's try something different now. What about using another scheduler?

We learned in the previous chapter how to use UIScheduler. However, there are more schedulers.

ReactiveCocoa brings a protocol called DateSchedulerType, which is used to trigger the signal according to time intervals. As it is a protocol, we can't instantiate it. We have to use a class that implements this protocol.

There is one class called QueueScheduler that implements DateSchedulerType. The only detail that we have to give to this class is the GCD queue that we desire to use. Here, we are going to use the main queue. However, for better performance, you can try to create your own queue afterwards.

Scroll up to the beginning of the viewDidLoad method and create a signal that is fired every 10 seconds, called tenSecondsSignal, with the following code...