...

/

Transformation Operators

Transformation Operators

Learn various ways to transform data flowing down the data stream using transformation operators.

Introduction to transformation operators

After digging through the filtering operators that enable you to perform some sort of data cleaning throughout the pipeline, you usually need to perform a more complex operation on the data flow, like transforming data from one type to another. You are already familiar with the Array.map function in JS, which “projects” every element from the array into another type, based on the function you provide as an argument. In RxJS, the same idea applies, except that you are transforming the stream of data from one type to another. This is achieved in RxJS via the transformation operators, which we will cover in this lesson.



*map (map, switchMap, concatMap, mergeMap)

RxJS provides multiple operators that allow you to map the data stream from one type to another.



map

We begin with the basic map operator, which is able to transform the values emitted from the source Observable into another type based on the “projection” function passed as a first argument. It is important to note that the data transformation happens as it is emitted by the source Observable, unlike the Array.map operator, ...