From the course: Learning RxJS

Unlock the full course today

Join today to access over 24,000 courses taught by industry experts.

Writing operators to transform data

Writing operators to transform data

From the course: Learning RxJS

Writing operators to transform data

- [Instructor] So far we've only been able to transform data once something subscribes to an observable, and data is passed to it. But sometimes we'll want to transform the data before a subscription gets to it and after an observable gets it. To extend our weather example, let's say we have a temperature object that has both the day of the week and a temperature value. We let users select from one of the seven days of the week, and input a temperature value. That can include decimals like 71.25. If we want to format this to the user, we can round down the temperature to the lowest whole number and abbreviate the day of the week. Instead of putting all of this logic in our subscription function, we can use something called an operator to transform our data. Here, I'm using something called the map operator to format our data. Operators in RHDS are mainly used to transform data paths to an observable. The change data…

Contents