1 00:00:00,360 --> 00:00:04,680 In this lecture, we are going to quickly recap the flattening operators. 2 00:00:04,950 --> 00:00:09,930 The overall goal of a flattening operator is to subscribe to inner observables. 3 00:00:10,260 --> 00:00:13,470 Their values will get pushed onto the next operator. 4 00:00:13,800 --> 00:00:17,250 They are much easier to use than chaining subscriber functions. 5 00:00:17,550 --> 00:00:22,350 We have various options at our disposal for creating a flattening operator. 6 00:00:22,890 --> 00:00:25,260 I'll give an analogy for each operator. 7 00:00:25,560 --> 00:00:27,660 Let's say you're a chef at a restaurant. 8 00:00:27,930 --> 00:00:32,340 As orders come in, you need to decide how to prioritize each order. 9 00:00:32,670 --> 00:00:37,230 There are various systems you can use for determining how to treat new orders. 10 00:00:37,500 --> 00:00:41,280 What would you do if an order comes in as you're working on another order? 11 00:00:41,790 --> 00:00:47,550 If you were to use the Switch Map operator, you would stop working on whatever order you were on. 12 00:00:47,910 --> 00:00:49,950 The latest order takes priority. 13 00:00:50,250 --> 00:00:52,890 Probably not the best idea to ditch an order. 14 00:00:53,070 --> 00:00:54,780 Let's look at a different option. 15 00:00:55,350 --> 00:01:02,280 The cat map operator dictates all orders are important, but only one order should be worked on at a 16 00:01:02,280 --> 00:01:02,730 time. 17 00:01:03,150 --> 00:01:06,870 The other orders are queued until the first order is complete. 18 00:01:07,350 --> 00:01:09,960 Orders are worked on in the order they are given. 19 00:01:10,650 --> 00:01:13,980 The Merge Map operator will accept all orders. 20 00:01:14,400 --> 00:01:16,560 Orders can be worked on in parallel. 21 00:01:16,830 --> 00:01:20,130 New orders do not impact existing active orders. 22 00:01:20,610 --> 00:01:26,850 Lastly, the exhaust map operator will ignore new orders until the active order is finished. 23 00:01:27,180 --> 00:01:30,960 Once the active order is completed, a new order can be given. 24 00:01:31,500 --> 00:01:35,670 As you can see, flattening operators come in all shapes and sizes. 25 00:01:35,940 --> 00:01:39,540 Learning how to use flattening operators is very important. 26 00:01:39,840 --> 00:01:44,790 It's likely you will run into a scenario where you'll need to manage inner subscriptions. 27 00:01:45,090 --> 00:01:50,370 Choosing the right operator will give you the desired behavior and effect you're looking for in your 28 00:01:50,370 --> 00:01:50,760 app. 29 00:01:51,270 --> 00:01:53,820 We're finished learning about our SJS. 30 00:01:54,030 --> 00:01:59,130 We spent a lot of time learning about observables and operators at this point. 31 00:01:59,340 --> 00:02:03,930 You should be more than comfortable with working with our SJS code in an app. 32 00:02:04,230 --> 00:02:10,330 Angular and other libraries use our SJS behind the scenes in the next couple of sections. 33 00:02:10,380 --> 00:02:12,360 We will encounter observables. 34 00:02:12,840 --> 00:02:18,510 Handling observables and angular is not much different than handling them with vanilla JavaScript. 35 00:02:18,780 --> 00:02:20,880 So when you're ready, I'll see you there.