Top mistakes in RxSwift you want to avoid

When we learn a new programming language or new frameworks we always do some mistakes. This is how we people learn things.

In this article, I’m want to show you my top 7 mistakes which I did during my Rx trials. I hope I will help you to avoid them 🙂.


Continue Reading

RxCaseStudy:
Default value after a countdown

Recently somebody asked me how he can send a default value if the stream hasn’t sent a new value in 5 minutes using RxSwift.

The final solution is short, however it uses few operators like merge, concat & flatMapLatest together which makes it more … advanced usage of Rx.

I thought it would be a great case-study for an article. So here it is! Enjoy reading 📚💪


Continue Reading

Combining Observables: combineLatest, withLatestFrom, zip

When it comes to writing an application in the reactive way, sooner or later your output will depend on more than just one Observable sequence. ReactiveX offers multiple operators to combine multiple Observables into one sequence.

Today I’ll describe what are the differences between combineLatest, withLatestFrom, zip and what are good scenarios to use them. Enjoy reading 💪📚


Continue Reading

Creating an Observable: create, just, deferred

RxSwiftCommunity is great and has already developed great Rx wrappers for existing API in iOS/mac world. However, you will always find a library or framework which doesn’t have Rx extension yet.

ReactiveX offers you 3 operators which you can use to wrap not-reactive code within an Observable. These operators are:

  • create()
  • just()
  • deferred()

What is the difference between them and when you should use which? These are the questions which I want to answer for. Enjoy reading 📚💪


Continue Reading

RxSwift: Reactive Programming with Swift
The book review

The last Friday evening and the whole weekend I spent with the first book about RxSwift. It took a couple of months to prepare the book for four authors however, it took me 2 days to read it 😅. What I’ve found in this book? Who will take the most advantage of reading it? Is it worth reading? This is my personal, subjective and honest opinion about it. Enjoy! 📚


Continue Reading

How to handle errors in RxSwift

In recent days MVVM become very popular architecture design for iOS apps. Especially when RxSwift starts to gain more and more popularity. In RxMVVM most of properties are expressed by Observables.

However, Observables terminate whenever they receive error or completed events. Termination means an Observable subscription won’t receive any new message. When I started to learn Rx I didn’t realize the consequences of this rule.

Do you have problems with errors handling? Did your Observable terminate unexpectedly and your button stopped sending tap events? This is what the article is about. Enjoy reading 📚💪


Continue Reading

RxTest – How to test the Observable in Swift

Few articles earlier I showed you how you can wrap presentation of UIAlertController with the Observable. Despite there weren’t any tests in the sample project, I’ve written the whole sample in TDD. I didn’t upload test files for the last time because I didn’t want to overload you 😃.

No matter how much RxSwift simplifies writing a code you should always write unit-tests. The feedback which tests provide is huge for the business and even for you because tests help you in revealing bad code smells in your architecture.

In this article, I want to show you all the tests I’ve written and how you can test the Observables with RxTest. Enjoy reading 📚💪


Continue Reading

The learning materials list for RxSwift

Reactive programming is awesome and really makes complex I/O stuff simple. However, FRP is totally different approach how you look at the events and programming. Such a change in thinking requires good quality materials which can make the learning process simpler and quicker. Here’s the list of materials which I’ve read and I’ve found them useful. The list is sorted in an order I would like to read it 😉


Continue Reading

Presenting the UIAlertController with RxSwift

Showing an action sheet seems not to be a typical use case for the Observable. My first implementation ended with multiple PublishSubject inside UIViewController and ViewModel. Multiple subscriptions inside Observable’s chain is usually a code smell. Of course, I didn’t have multiple subscribe method calls inside my code, but only a few bindings with bindTo. However, bindTo is just a wrapper over the subscribe method. In the end, I missed the sign of the code smell.

In this article, I want to show you how you can separate presentation of UIAlertController from the UIViewController. Moreover, I want to show you how to do implement it using the RxSwift.


Continue Reading

Write snapshot tests!

Today’s topic is not connected with RxSwift at all. Recently, I’ve started using an awesome library so I decided to write an article about it, because it’s worth to mention. Don’t worry, I will come back with reactive stuff soon 😉

I hope you know how important unit tests are in writing software applications. In case you don’t know I recommend you my article series and Jon’s Raid website about unit tests in the iOS world.

However, it is difficult (or even impossible) to cover all the code you have with tests. Writing unit tests for classes inherited from UIView was a hard task for me, because the outcome was not worth the time spent on it. As a result, I stopped writing unit tests for any of views.

In my last project, a colleague of mine introduced me FBSnapshotTestCase library developed by Facebook.


Continue Reading