Reactive Programming with Swift 4
eBook - ePub

Reactive Programming with Swift 4

  1. English
  2. ePUB (mobile friendly)
  3. Available on iOS & Android
eBook - ePub

Reactive Programming with Swift 4

About this book

Learn how to solve blocking user experience and build event based reactive applications with Swift.About This Book• Build fast and scalable apps with RxSwift• Apply reactive programming to solve complex problems and build efficient programs with reactive user interfaces• Take expressiveness, scalability, and maintainability of your Swift code to the next level with this practical guideWho This Book Is ForThis book is for the developers who are familiar with Swift and iOS application development and are looking out to reduce the complexity of their apps. Prior experience of reactive programming is not necessary.What You Will Learn• Understand the practical benefits of Rx on a mobile platform• Explore the building blocks of Rx, and Rx data flows with marble diagrams• Learn how to convert an existing code base into RxSwift code base• Learn how to debug and test your Rx Code• Work with Playgrounds to transform sequences by filtering them using map, flatmap and other operators• Learn how to combine different operators to work with Events in a more controlled manner.• Discover RxCocoa and convert your simple UI elements to Reactive components• Build a complete RxSwift app using MVVM as design patternIn DetailRxSwift belongs to a large family of Rx implementations in different programming languages that share almost identical syntax and semantics. Reactive approach will help you to write clean, cohesive, resilient, scalable, and maintainable code with highly configurable behavior.This book will introduce you to the world of reactive programming, primarily focusing on mobile platforms. It will tell how you can benefit from using RxSwift in your projects, existing or new. Further on, the book will demonstrate the unbelievable ease of configuring asynchronous behavior and other aspects of the app that are traditionally considered to be hard to implement and maintain. It will explain what Rx is made of, and how to switch to reactive way of thinking to get the most out of it. Also, test production code using RxTest and the red/ green approach. Finally, the book will dive into real-world recipes and show you how to build a real-world app by applying the reactive paradigm.By the end of the book, you'll be able to build a reactive swift application by leveraging all the concepts this book takes you through.Style and approachThis book is a definite tutorial in FRP with Swift filled with well-described examples.

Tools to learn more effectively

Saving Books

Saving Books

Keyword Search

Keyword Search

Annotating Text

Annotating Text

Listen to it instead

Listen to it instead

Information

Reduce by Combining and Filtering and Common Trade Offs

Sometimes we want to work with multiple Observable sequences, reacting to new elements emitted from one or more of those sequences. There are a handful of operators that combine Observable sequences in a variety of ways. In this chapter, we will explore such operators that allow us to combine and filter Observable sequences.
In this chapter, we will cover the following topics:
  • Concatenating and prefixing
  • Merging
  • Zipping
  • Performing side effects
  • Creating a demo application to cover all the topics covered so far

Combining and filtering Observable sequences

In the previous chapters, we learned how to create, transform, and filter Observable sequences. You would have found a lot of similarities between filtering of RxSwift, transforming operators, and traditional Swift's standard collection methods. You got acquainted with the true power of RxSwift while working with operators such as flatMap where you had to write very little code to get a great deal of work done.
This chapter will show you various techniques with which you can assemble and combine sequences to control data as desired. Before delving into the concepts, let's set up the project first.

Project setup

As discussed earlier, let's set up a workspace to work with RxSwift:
  1. Create a single view application project and name it RxAdvancedOperators.
  2. Open Terminal.app and navigate to the project folder. Create a podfile inside your Xcode projects folder by executing the pod init command. Once the command is executed, you will see a Podfile in the project folder:
  3. Open the created Podfile and paste the Podfile code:
# Uncomment the next line to define a global platform for your project


target 'RxAvancedOperators' do
# Comment the next line if you're not using Swift ...

Table of contents

  1. Title Page
  2. Copyright and Credits
  3. Packt Upsell
  4. Contributors
  5. Preface
  6. Migrating from Swift 3 to Swift 4
  7. FRP Fundamentals, Terminology, and Basic Building Blocks
  8. Set up RxSwift and Convert a Basic Login App to its RxSwift Counterpart
  9. When to Become Reactive?
  10. Filter, Transform, and Simplify
  11. Reduce by Combining and Filtering and Common Trade Offs
  12. React to UI Events – Start Subscribing
  13. RxTest and Custom Rx Extensions – Testing with Rx
  14. Testing Your RxCode – Testing Asynchronous Code
  15. Schedule Your Tasks, Don't Queue!
  16. Subscribe to Errors and Save Your App
  17. Functional and Reactive App-Architecture
  18. Finish a Real-World Application
  19. Other Books You May Enjoy

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn how to download books offline
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 990+ topics, we’ve got you covered! Learn about our mission
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more about Read Aloud
Yes! You can use the Perlego app on both iOS and Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app
Yes, you can access Reactive Programming with Swift 4 by Navdeep Singh in PDF and/or ePUB format, as well as other popular books in Computer Science & Operating Systems. We have over one million books available in our catalogue for you to explore.