You are previewing Reactive Programming with Swift.
O'Reilly logo
Reactive Programming with Swift

Book Description

Leverage the power of the Functional Reactive Programming paradigm with Swift to develop robust iOS applications

About This Book

  • Build highly responsive applications with this practical introduction to Reactive programming

  • This book uses ReactiveCocoa, the most popular solution for Reactive Programming on iOS to install, debug, and develop a framework with Swift

  • Switch from the traditional programming style to the reactive paradigm to code your first reactive applications with ease

  • Who This Book Is For

    Reactive Programming with Swift is for Swift developers who want to start making more powerful and efficient applications. You need a basic understanding of Swift to follow along. This book takes a first-principles approach to what Reactive Programming is and how you can start implementing it in your next iOS applications.

    What You Will Learn

  • Switch your programming concepts from imperative to Functional reactive programming

  • Improve your app’s maintenance by developing with a different paradigm

  • Create unit tests and automation tests using the ReactiveCocoa framework

  • Create clear code that is very easy to read

  • Get accustomed to migrating mobile apps to the Reactive way of programming

  • Perform asynchronous calls and join them later

  • In Detail

    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.

    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.

    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.

    Style and approach

    This book is a fast-paced, practical guide compiled with ample images and screenshots that explain how to create apps and demonstrate their logic.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

    Table of Contents

    1. Reactive Programming with Swift
      1. Reactive Programming with Swift
      2. Credits
      3. About the Author
      4. About the Reviewer
      5. www.PacktPub.com
        1. Why subscribe?
        2. Free access for Packt account holders
      6. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book 
          3. Errata
          4. Piracy
          5. Questions
      7. 1. Introduction to Reactive Programming
        1. What is reactive programming?
          1. The history of reactive programming
        2. Paradigms - declarative versus imperative
        3. What is functional programming?
          1. Choosing reactive programming
        4. Swift - interactive, safe, and fast
        5. The ReactiveCocoa project
          1. ReactiveCocoa extensions
          2. Migrating to ReactiveCocoa
        6. The future of reactive programming
        7. Summary
      8. 2. Installing ReactiveCocoa and Using It with Playground
        1. The ReactiveCocoa website
        2. Exploring ReactiveCocoa
        3. Installing ReactiveCocoa via CocoaPods
          1. Installing CocoaPods without administrator permission
          2. Installing CocoaPods with Carthage
        4. Using Playground
        5. Summary
      9. 3. Performing UI Events with ReactiveCocoa
        1. An overview of the project
        2. Setting up the project
        3. Creating a validator class
        4. Validating text fields
        5. Enabling and disabling the button
        6. Using UIDatePicker
        7. Selecting the gender of the user
        8. Adding more information
        9. Getting the right input type
        10. Using bidirectional channels
        11. Displaying your horoscope
        12. Summary
      10. 4. Network and Change Propagation
        1. Overviewing the project
        2. Setting up the project
        3. Searching for a movie
          1. Creating signals
          2. Handling errors
        4. Filling in the table view
        5. Model-View-ViewModel bindings
        6. Displaying movie posters
        7. Improving your code for a second scene
        8. Filling in the movie form
        9. Implementing the genre signal
        10. Changing a few details in the first scene
        11. Summary
      11. 5. Enhance Your Application Using RAC Extensions
        1. An overview of the project
        2. Setting up the project and installing extensions
        3. Mocking up the first scene
        4. Retrieving information from GPS
          1. Signaling
        5. Taking pictures with a camera
        6. Using gesture recognizers
        7. Storing pictures
          1. Saving pictures to the photo library
        8. Storing coordinates
        9. Showing coordinates
        10. Summary
      12. 6. Using the ReactiveCocoa 4 Style
        1. An overview of the project
        2. Setting up the project
        3. Developing the Currency class
        4. Creating the Currency Manager
        5. Creating the Product class
        6. Implementing a shopping cart
        7. Resuming the ViewController class
        8. Creating the checkout scene
        9. Testing the application
        10. Summary
      13. 7. Testing Your Application
        1. Checking the expected results
        2. Creating unit tests
          1. Using signals for checking the results
          2. Testing an asynchronous signal
        3. Testing the UI
        4. Profiling with Instruments
        5. Summary
      14. 8. Migrating a Real Application to ReactiveCocoa
        1. Knowing the application
        2. Creating a new framework
        3. Replacing the airplane delegate
        4. Reorganizing the signals
        5. Checking the dark side
        6. Splitting the signal again
        7. Waiting for 10 seconds
        8. Reversing the geolocation
        9. Avoiding repeated calls
        10. Summary