1 00:00:00,930 --> 00:00:05,650 Let's go back to our joint order service and build our two publishers for the events that we just created. 2 00:00:05,650 --> 00:00:09,750 So inside the SRT directory I'll make a new folder of events. 3 00:00:09,780 --> 00:00:16,710 Then inside there I'll make a new folder of publishers and side that I'm going to make two files one 4 00:00:16,720 --> 00:00:27,070 I will call order created publisher and Order cancelled publisher. 5 00:00:27,300 --> 00:00:29,700 Let's start off first with our order created publisher. 6 00:00:29,700 --> 00:00:34,560 So remember what we need to import at the top the file we need to make sure we get our publisher base 7 00:00:34,560 --> 00:00:35,320 class. 8 00:00:35,340 --> 00:00:46,820 We also need to get our order created event so we'll get our publisher order created event. 9 00:00:46,850 --> 00:00:51,020 And we also need that subjects them as well so we can specify the subject we should use when we publish 10 00:00:51,020 --> 00:00:51,610 this event. 11 00:00:52,160 --> 00:00:56,480 So subjects and I'll get all that from my company module 12 00:00:59,410 --> 00:01:06,630 then inside of here we will export a new class called order created publisher that's gonna be extending 13 00:01:06,660 --> 00:01:07,860 our publisher base class. 14 00:01:07,890 --> 00:01:12,420 And remember this is a generic class where we stick in the event that we're going to eventually emit 15 00:01:13,690 --> 00:01:21,950 so order created even were then told right away by typescript that we need to define that abstract property 16 00:01:22,710 --> 00:01:28,100 so we could say that we're going to have a subject property we're going to annotate this properties 17 00:01:28,110 --> 00:01:38,750 type as subjects dot order created and the value for it will be subjects dot order created and that's 18 00:01:38,750 --> 00:01:40,330 very much it. 19 00:01:40,380 --> 00:01:44,190 Now any time that you want to publish an event saying that an order has been created we would write 20 00:01:44,190 --> 00:01:49,820 out something like new order created publisher. 21 00:01:50,060 --> 00:01:57,460 Remember we will throw in our Nats client and then we would call publish and inside this object right 22 00:01:57,460 --> 00:01:59,800 here we'd pass all of our different data properties. 23 00:01:59,800 --> 00:02:04,900 So in our case that would be the idea of the order the user I.D. the status expires at and then some 24 00:02:04,900 --> 00:02:06,810 information about the ticket itself. 25 00:02:06,850 --> 00:02:08,840 That's pretty much it. 26 00:02:09,030 --> 00:02:12,740 Let's not repeat the same process for the order canceled publisher as well. 27 00:02:13,200 --> 00:02:16,950 So here's order it canceled publisher at the top. 28 00:02:16,960 --> 00:02:25,170 We will once again do a import for subjects publisher and order canceled 29 00:02:29,410 --> 00:02:33,680 from the common module will export a class of order canceled. 30 00:02:33,710 --> 00:02:42,490 Publisher and that's going to be extending our publisher base class throw in our order a canceled event 31 00:02:44,100 --> 00:02:47,250 and then once again we need to define the subject property on here. 32 00:02:47,250 --> 00:02:50,460 So our subject will be of type subject subjects. 33 00:02:50,610 --> 00:02:54,560 Order canceled and its value will be subject Scott. 34 00:02:54,690 --> 00:02:55,930 Order canceled. 35 00:02:56,070 --> 00:02:56,520 And that's it. 36 00:02:59,160 --> 00:03:01,970 Well that's all we have to do to define a publisher inside of here. 37 00:03:02,490 --> 00:03:03,570 So this is looking pretty good. 38 00:03:03,570 --> 00:03:04,830 Let's take a pause right here. 39 00:03:04,830 --> 00:03:09,840 We're going to go back over to our two root handlers in the next video and make use of these two publishers 40 00:03:10,020 --> 00:03:12,390 to make sure that we publish some events at the appropriate time.