RxSwift basics

suggest change

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

Every piece of data can be represented as an Observable, an asynchronous stream. FRP represents both synchronous and asynchronous events as streams and gives them the same interface.

An Observable emits zero or more .Next values, then terminates with .Completed or .Error. Early RxSwift used those capitalized names. Later versions use .next, .completed, and .error. There is no .Success event.

Let’s take a look at following marble diagram:

--(1)--(2)--(3)|-->

This is a stream of Int values. Three .Next events occur, and then the stream completes.

--X->

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. Read the examples, the docs, and the getting-started guide.
  2. RxSwift Slack room has channels for learning and problem solving.
  3. Play with RxMarbles to see what an operator does and which one fits the case.
  4. Take a look on this example, explore the code by yourself.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents