Pipes and Operators
Learn how to use pipes and operators to modify the value emitted from an observable.
We'll cover the following
In some cases, we may not want to directly deal with the values from an observable. We may need to filter and transform it before delivering it to the observer. RxJS allows us to transform an observable by using pipes and operators.
Understanding operators
An operator is a technical term for a function. Plain and simple. An operator takes in an observable, transforms it, and spits out a brand new observable. We can use an operator to alter the value.
Using an operator
The current observable will emit the event
object. This is because we’re listening for the input
event on the <input>
element. Let’s say rather than returning the entire event
object, we just want to return the value in the input.
We can use an operator to change how the observable initially behaves. Let’s update our code to the following:
Get hands-on with 1400+ tech skills courses.