1 00:00:00,150 --> 00:00:05,850 In this lecture, we are going to learn about the Con Cap Map operator for queuing observables. 2 00:00:06,240 --> 00:00:12,630 It's another operator for flattening and observable inner observables are automatically subscribed by 3 00:00:12,630 --> 00:00:13,560 this operator. 4 00:00:13,860 --> 00:00:20,130 Values emitted by the inner observable are pushed to the stream similar to the Switch map. 5 00:00:20,160 --> 00:00:25,530 Operator This operator will limit the number of active observables to one. 6 00:00:25,900 --> 00:00:30,600 However, the most significant difference is how it treats newer subscriptions. 7 00:00:30,900 --> 00:00:36,930 Instead of cancelling the previous observable, this operator will place observables into a queue. 8 00:00:37,260 --> 00:00:43,620 The next observable in the queue will not be subscribed to until the current active observable has been 9 00:00:43,620 --> 00:00:44,280 completed. 10 00:00:44,970 --> 00:00:49,350 In this example, the interval operator will push values forever. 11 00:00:49,890 --> 00:00:53,190 If a new observable is created, it'll be cued. 12 00:00:53,520 --> 00:00:57,880 Theoretically, the newer observable will never receive a subscription. 13 00:00:57,900 --> 00:01:04,290 Since the first observable never completes, this operator can be helpful when you want to give every 14 00:01:04,290 --> 00:01:06,840 observable a chance to emit values. 15 00:01:07,110 --> 00:01:14,700 Be warned If inner observable are left unmanaged, you can potentially face a traffic jam of observables. 16 00:01:16,150 --> 00:01:20,440 Let's look at an example of how can count map operator works. 17 00:01:20,770 --> 00:01:23,500 First, we need to import this operator. 18 00:01:23,830 --> 00:01:28,180 Update the import statement to include the Icon Cap Map operator. 19 00:01:30,690 --> 00:01:36,270 Next, we will replace the Switch map operator with the Icon Cap Map operator. 20 00:01:38,740 --> 00:01:41,830 Let's test our application with throttling turned on. 21 00:01:44,220 --> 00:01:49,320 Let's click the button five times each request will be performed one at a time. 22 00:01:49,650 --> 00:01:54,480 The next request does not begin until the previous request has been completed. 23 00:01:54,840 --> 00:01:58,080 They're being cued by the Con Cap Map operator. 24 00:01:58,620 --> 00:02:05,010 Overall, the Con Cap Map Operator is great for queuing observables with a finite lifespan. 25 00:02:05,370 --> 00:02:11,730 We can have the best of both worlds by maintaining a single active observable without cancelling previous 26 00:02:11,730 --> 00:02:12,660 observables. 27 00:02:12,960 --> 00:02:15,510 We are still responsible for completing them. 28 00:02:15,900 --> 00:02:19,170 Be sure to manage or observables with this operator. 29 00:02:19,440 --> 00:02:24,660 Otherwise, other observables may not be able to run in the next lecture. 30 00:02:24,810 --> 00:02:28,080 We are going to explore one more flattening operator.