In this lecture, we are going to discuss the purpose of a Piper Ball.
Operator, we want to dive into some theory before writing code creation operators are a small portion
of the SJS library.
A lot of operators in our exchanges are pipe able operators.
Unlike creation operators, pipe cable operators are concerned with transforming, filtering and combining
data.
They can perform various actions on a stream of data before it gets pushed to an observer.
We're not going to be able to explore every single pipe cable operator.
We will focus on the most popular operators in our SJS.
Don't worry.
Understanding a few operators will take you very far with our SJS.
The rest of the operators are for edge cases you may come across from time to time.
They can fill in the gaps when you're struggling with a particular stream of data.
By the end of this section, you will become comfortable with using operators.
Picking up new operators will be a breeze.
Applying a pipe cable operator is simple.
They must be supplied with an observable.
The output of a pipe mobile operator is another observable.
The new observable will push data, but with the effect applied by the operator.
Instead of subscribing to the original observable, we will be able to subscribe to the newly created
observable.
Writing and observable can be a tricky business.
First, we need to create a new observable.
Second, we need to create an operator function.
Pipe able operators don't accept inexorable right away.
We need to configure them.
The function returned by the operator will be able to handle accepting and returning an observable.
We can pass on our observable to the function.
The new observable should be stored in a variable.
If we want to apply multiple operators, we would have to repeat the last two steps.
You're probably confused at this point.
It can be difficult to wrap your head around this syntax.
Luckily, it's not common to use paper bill operators in this manner.
We can altogether avoid this syntax.
Our SJS has a function for simplifying this entire process.
Observables have a pipe method for composing operators.
This solution will function the same as the previous solution.
Instead of managing the observables, the pipe function will handle passing on the observable to each
operator in the pipe function.
This feature leaves us with handling, creating the operator with its configuration settings.
The word pipe a ball comes from having to pass these operators into the pipe function.
Aside from having less code to write, it becomes visually clear as to how data will be streamed.
The pipe function will apply the operators in the order they are passed in.
In the end, the pipe function will spit out an observable.
We can directly subscribe to the pipe function to start listening for values whenever a new value is
pushed from the original observable.
It'll make its way down the pipeline.
Eventually, it will reach the observer.
Operators are pure.
They do not impact the original observable.
Theoretically, we can create another subscription directly on the original observable.
We can even compose a completely different set of operators.
And this example, the observers are expected to receive different streams of data.
As you can see, pipe able operators are the horsepower behind our SJS.
We can declaratively manipulate streams of data with powerful operators in the next lecture.
We are going to start writing some pipe aboul operators.