1 00:00:00,150 --> 00:00:03,900 In this lecture, we are going to discuss the purpose of a Piper Ball. 2 00:00:03,930 --> 00:00:10,950 Operator, we want to dive into some theory before writing code creation operators are a small portion 3 00:00:10,950 --> 00:00:13,020 of the SJS library. 4 00:00:13,380 --> 00:00:17,490 A lot of operators in our exchanges are pipe able operators. 5 00:00:17,940 --> 00:00:25,350 Unlike creation operators, pipe cable operators are concerned with transforming, filtering and combining 6 00:00:25,350 --> 00:00:25,800 data. 7 00:00:26,130 --> 00:00:32,220 They can perform various actions on a stream of data before it gets pushed to an observer. 8 00:00:32,580 --> 00:00:36,660 We're not going to be able to explore every single pipe cable operator. 9 00:00:36,960 --> 00:00:41,320 We will focus on the most popular operators in our SJS. 10 00:00:41,970 --> 00:00:42,690 Don't worry. 11 00:00:42,930 --> 00:00:47,580 Understanding a few operators will take you very far with our SJS. 12 00:00:47,910 --> 00:00:52,950 The rest of the operators are for edge cases you may come across from time to time. 13 00:00:53,370 --> 00:00:57,690 They can fill in the gaps when you're struggling with a particular stream of data. 14 00:00:58,050 --> 00:01:02,820 By the end of this section, you will become comfortable with using operators. 15 00:01:03,150 --> 00:01:05,910 Picking up new operators will be a breeze. 16 00:01:06,570 --> 00:01:09,420 Applying a pipe cable operator is simple. 17 00:01:09,780 --> 00:01:12,240 They must be supplied with an observable. 18 00:01:12,510 --> 00:01:16,380 The output of a pipe mobile operator is another observable. 19 00:01:16,710 --> 00:01:21,750 The new observable will push data, but with the effect applied by the operator. 20 00:01:22,080 --> 00:01:28,380 Instead of subscribing to the original observable, we will be able to subscribe to the newly created 21 00:01:28,380 --> 00:01:29,190 observable. 22 00:01:29,910 --> 00:01:32,640 Writing and observable can be a tricky business. 23 00:01:32,820 --> 00:01:36,030 First, we need to create a new observable. 24 00:01:36,690 --> 00:01:39,960 Second, we need to create an operator function. 25 00:01:40,260 --> 00:01:43,860 Pipe able operators don't accept inexorable right away. 26 00:01:43,950 --> 00:01:45,510 We need to configure them. 27 00:01:46,020 --> 00:01:51,960 The function returned by the operator will be able to handle accepting and returning an observable. 28 00:01:52,260 --> 00:01:55,440 We can pass on our observable to the function. 29 00:01:55,800 --> 00:01:58,890 The new observable should be stored in a variable. 30 00:01:59,460 --> 00:02:05,280 If we want to apply multiple operators, we would have to repeat the last two steps. 31 00:02:05,640 --> 00:02:07,740 You're probably confused at this point. 32 00:02:08,039 --> 00:02:11,220 It can be difficult to wrap your head around this syntax. 33 00:02:11,400 --> 00:02:15,990 Luckily, it's not common to use paper bill operators in this manner. 34 00:02:16,260 --> 00:02:18,780 We can altogether avoid this syntax. 35 00:02:19,050 --> 00:02:23,610 Our SJS has a function for simplifying this entire process. 36 00:02:24,270 --> 00:02:28,620 Observables have a pipe method for composing operators. 37 00:02:29,010 --> 00:02:32,760 This solution will function the same as the previous solution. 38 00:02:33,090 --> 00:02:39,690 Instead of managing the observables, the pipe function will handle passing on the observable to each 39 00:02:39,690 --> 00:02:41,730 operator in the pipe function. 40 00:02:42,150 --> 00:02:47,880 This feature leaves us with handling, creating the operator with its configuration settings. 41 00:02:48,210 --> 00:02:53,550 The word pipe a ball comes from having to pass these operators into the pipe function. 42 00:02:54,240 --> 00:03:00,600 Aside from having less code to write, it becomes visually clear as to how data will be streamed. 43 00:03:01,020 --> 00:03:05,370 The pipe function will apply the operators in the order they are passed in. 44 00:03:06,000 --> 00:03:09,810 In the end, the pipe function will spit out an observable. 45 00:03:10,080 --> 00:03:16,770 We can directly subscribe to the pipe function to start listening for values whenever a new value is 46 00:03:16,770 --> 00:03:19,050 pushed from the original observable. 47 00:03:19,150 --> 00:03:21,210 It'll make its way down the pipeline. 48 00:03:21,450 --> 00:03:23,850 Eventually, it will reach the observer. 49 00:03:24,360 --> 00:03:25,950 Operators are pure. 50 00:03:26,190 --> 00:03:28,950 They do not impact the original observable. 51 00:03:29,220 --> 00:03:34,890 Theoretically, we can create another subscription directly on the original observable. 52 00:03:35,160 --> 00:03:39,220 We can even compose a completely different set of operators. 53 00:03:39,480 --> 00:03:44,850 And this example, the observers are expected to receive different streams of data. 54 00:03:45,450 --> 00:03:51,060 As you can see, pipe able operators are the horsepower behind our SJS. 55 00:03:51,360 --> 00:03:57,990 We can declaratively manipulate streams of data with powerful operators in the next lecture. 56 00:03:58,140 --> 00:04:01,650 We are going to start writing some pipe aboul operators.