Swift Language RxSwift RxSwift basics


FRP, or Functional Reactive Programming, has some basic terms which you need to know.

Every piece of data can be represented as Observable, which is an asynchronous data stream. The power of FRP is in representation synchronous and asynchronous events as streams, Observables, and providing the same interface to work with it.

Usually Observable holds several (or none) events that holds the date - .Next events, and then it can be terminated successfully (.Success) or with an error (.Error).

Let's take a look at following marble diagram:


In this example there is a stream of Int values. As time moves forward, three .Next events occurred, and then the stream terminated successfully.


The diagram above shows a case where no data was emitted and .Error event terminates the Observable.

Before we move on, there are some useful resources:

  1. RxSwift. Look at examples, read docs and getting started.
  2. RxSwift Slack room has a few channels for education problem solving.
  3. Play around with RxMarbles to know what operator does, and which is the most useful in your case.
  4. Take a look on this example, explore the code by yourself.