In this lecture, we are going to quickly recap the flattening operators.
The overall goal of a flattening operator is to subscribe to inner observables.
Their values will get pushed onto the next operator.
They are much easier to use than chaining subscriber functions.
We have various options at our disposal for creating a flattening operator.
I'll give an analogy for each operator.
Let's say you're a chef at a restaurant.
As orders come in, you need to decide how to prioritize each order.
There are various systems you can use for determining how to treat new orders.
What would you do if an order comes in as you're working on another order?
If you were to use the Switch Map operator, you would stop working on whatever order you were on.
The latest order takes priority.
Probably not the best idea to ditch an order.
Let's look at a different option.
The cat map operator dictates all orders are important, but only one order should be worked on at a
time.
The other orders are queued until the first order is complete.
Orders are worked on in the order they are given.
The Merge Map operator will accept all orders.
Orders can be worked on in parallel.
New orders do not impact existing active orders.
Lastly, the exhaust map operator will ignore new orders until the active order is finished.
Once the active order is completed, a new order can be given.
As you can see, flattening operators come in all shapes and sizes.
Learning how to use flattening operators is very important.
It's likely you will run into a scenario where you'll need to manage inner subscriptions.
Choosing the right operator will give you the desired behavior and effect you're looking for in your
app.
We're finished learning about our SJS.
We spent a lot of time learning about observables and operators at this point.
You should be more than comfortable with working with our SJS code in an app.
Angular and other libraries use our SJS behind the scenes in the next couple of sections.
We will encounter observables.
Handling observables and angular is not much different than handling them with vanilla JavaScript.
So when you're ready, I'll see you there.