4275 views

In this new series we focus on operators for Reactive Programming. They are essential to react to data in your application.

1 – Introduction to Event Streams

2 – Transformation Operator Map

The map operator is a common way of transforming values emitted over time. In the following example, it passes each value through a transformation function “colored to black & white“:

3 – Horizontal Combination Operator Scan

Like map, the scan operator applies a function to a stream of values: an accumulator function. It also takes a second seed argument, the initial accumulator value:

4 – Time Shift Operator Delay

Map and scan take a transformation function as a parameter. On the other hand, the delay operator takes a number of milliseconds. It time shifts each event by this amount of time:

5 – Vertical Combination Operator Zip

Scan combines horizontally the events of a single event stream. On the other hand, zip combines vertically the events of multiple event streams. It takes the n-th color and n-th shape to produce the n-th coloredShape:

6 – Vertical Combination Operator CombineLatest

Similarly to zip, combineLatest merges the events of multiple event streams. But whenever any event stream emits a value, combineLatest computes a new coloredShape using the latest color and the latest shape:

A new animated series will start soon. Follow us to catch it!