1 00:00:01,500 --> 00:00:03,410 All right my friends let's open up that ComEd module. 2 00:00:03,420 --> 00:00:05,700 We're gonna make the two updates we just discussed. 3 00:00:05,700 --> 00:00:07,750 Well first start off inside of our base listener. 4 00:00:07,840 --> 00:00:12,030 So inside the base listener class are going to find the private client property and are going to change 5 00:00:12,030 --> 00:00:14,960 it to protected. 6 00:00:15,010 --> 00:00:16,830 I'm also going to go over to the publisher. 7 00:00:16,840 --> 00:00:18,220 So here's based publisher. 8 00:00:18,220 --> 00:00:22,950 This thing also gets a client inside there we had Martha client as private. 9 00:00:23,020 --> 00:00:24,360 We don't have to. 10 00:00:24,550 --> 00:00:28,630 We don't have to change this private thing over to protected but there might be a scenario at some point 11 00:00:28,670 --> 00:00:34,000 in the future where maybe we want to get access to the client inside of a subclass of publisher. 12 00:00:34,000 --> 00:00:39,100 So not not important not required right now but it's entirely possible that we might want to use this 13 00:00:39,100 --> 00:00:40,220 at some point in the future. 14 00:00:40,420 --> 00:00:46,890 So just thinking forward I'm also gonna change this thing to protected as well. 15 00:00:46,960 --> 00:00:48,970 So that's those two changes. 16 00:00:48,970 --> 00:00:53,240 So now we're going to go over to our ticket updated event and make sure that it says that there's going 17 00:00:53,240 --> 00:00:56,240 to be an order I.D. attached to this thing as well. 18 00:00:56,920 --> 00:00:57,710 So here's my ticket. 19 00:00:57,730 --> 00:00:59,190 Updated event file. 20 00:00:59,200 --> 00:01:05,530 I'm going to add in order I.D. I'm going to market as optional because it is possible that we are going 21 00:01:05,530 --> 00:01:08,650 to update that ticket and then it will not have a defined order. 22 00:01:08,660 --> 00:01:12,850 I.D. put in order I.D. And that's gonna be a string 23 00:01:15,990 --> 00:01:16,380 now. 24 00:01:16,380 --> 00:01:17,290 Quick question here. 25 00:01:17,310 --> 00:01:20,670 Should we add in the order I.D. property to ticket created. 26 00:01:20,670 --> 00:01:25,930 Well when we first create a ticket it is definitely not going to be initially assigned to an order whatsoever. 27 00:01:25,930 --> 00:01:30,410 And that's just something that cannot happen and is very unlikely to happen inside of application. 28 00:01:30,420 --> 00:01:36,180 So me personally I would not add in an order I.D. property to be ticket created event because the order 29 00:01:36,180 --> 00:01:41,820 I.D. even if we provide it would always be set to null or undefined but that's just me you might say 30 00:01:41,820 --> 00:01:45,500 hey I want make sure that all my events look really consistent as much as possible. 31 00:01:45,540 --> 00:01:46,510 So if you wanted to. 32 00:01:46,530 --> 00:01:49,230 Sure go ahead add in order I.D. to the ticket credit event. 33 00:01:49,260 --> 00:01:52,420 But again for me not a requirement. 34 00:01:52,680 --> 00:01:54,580 So we made our changes to the common module. 35 00:01:54,750 --> 00:01:59,790 Now as usual we're going to limit those changes publish them and then update the version of the common 36 00:01:59,820 --> 00:02:02,190 module used inside of our tickets service 37 00:02:05,620 --> 00:02:06,520 back at my terminal. 38 00:02:06,520 --> 00:02:11,800 I'll change into the common module and do that NPM run pub 39 00:02:16,410 --> 00:02:22,800 and after a second or two we should be published. 40 00:02:23,170 --> 00:02:32,960 I'll then go back over to my ticket service I'll do an NPM update for my coming module naturally the 41 00:02:32,960 --> 00:02:34,580 name of your modules can me slightly different 42 00:02:39,020 --> 00:02:39,960 looks good. 43 00:02:39,960 --> 00:02:44,070 And then while we're doing updates I'm also gonna update the version used inside the order module as 44 00:02:44,070 --> 00:02:44,760 well. 45 00:02:44,760 --> 00:02:48,900 Now when we update this version it might result in us seeing an error or two when we go backwards the 46 00:02:48,900 --> 00:02:49,830 order service. 47 00:02:49,830 --> 00:02:54,720 But I think it's just easier for us to update all of our services simultaneously while we're doing this 48 00:02:54,720 --> 00:03:01,020 update really quickly I'm also gonna go over to orders and do an update of that come module as well. 49 00:03:07,930 --> 00:03:08,280 OK. 50 00:03:08,350 --> 00:03:09,480 Very good. 51 00:03:09,490 --> 00:03:12,490 Now back inside of my order created listener. 52 00:03:12,490 --> 00:03:15,580 We finally get to enjoy the fruits of all the changes we just made. 53 00:03:15,790 --> 00:03:19,200 So first off inside of here we do not need the import for wrapper at the top. 54 00:03:19,240 --> 00:03:19,990 So I'll delete that 55 00:03:23,090 --> 00:03:28,370 then down here when we create the publisher rather than reaching out to some other file or other class 56 00:03:28,670 --> 00:03:33,890 we should be able to just access the client property on our listener itself. 57 00:03:33,950 --> 00:03:38,000 So I should be able to write in this client and have everything work. 58 00:03:38,000 --> 00:03:42,590 Now if you write in this client and you get an error chances are typescript is still taking a look at 59 00:03:42,590 --> 00:03:45,100 the old version of your coming module. 60 00:03:45,200 --> 00:03:49,790 So if you see an error right there the first thing to do is to either restart your editor or if you're 61 00:03:49,790 --> 00:03:59,810 using Visual Studio code remember you can hit a manned shift P search for reload window run that that's 62 00:03:59,810 --> 00:04:03,560 going to reboot the typescript type checker and now hopefully that error is going to go away. 63 00:04:04,220 --> 00:04:06,940 If you still see an error then there's probably something else going on. 64 00:04:07,070 --> 00:04:11,580 You want to take a look at the area and figure out what's happening okay. 65 00:04:11,640 --> 00:04:12,260 That's it. 66 00:04:12,270 --> 00:04:15,170 We've now got our publisher being initialized inside of here. 67 00:04:15,210 --> 00:04:18,630 We're passing through the client that the listener is using. 68 00:04:18,660 --> 00:04:19,920 Awesome. 69 00:04:19,920 --> 00:04:24,480 Now above all this is actually a really good example of how we can have a listener that publishes its 70 00:04:24,480 --> 00:04:25,700 own events. 71 00:04:25,740 --> 00:04:27,400 It's pretty much the formula for it. 72 00:04:27,420 --> 00:04:31,470 We're just going to import the publisher into the listener bring an instance of the publisher provide 73 00:04:31,470 --> 00:04:33,230 the client and then publish an event. 74 00:04:33,300 --> 00:04:36,750 Simple enough the last thing we're going to do. 75 00:04:36,780 --> 00:04:37,980 We've created our publisher. 76 00:04:37,980 --> 00:04:42,140 Now it's time to actually publish our event so we'll chain on a publish at the very end. 77 00:04:43,790 --> 00:04:47,730 And then we'll publish information about the ticket that we had just saved. 78 00:04:47,730 --> 00:04:51,720 So if we forget we can always mouse over and we will be told about all the different properties we have 79 00:04:51,720 --> 00:04:52,860 to provide. 80 00:04:52,860 --> 00:04:55,620 So I.T. version title blah blah blah. 81 00:04:55,650 --> 00:04:56,580 All that stuff. 82 00:04:56,580 --> 00:05:01,590 So we'll just throw it all in there just you know we could probably just solve this by throwing in the 83 00:05:01,590 --> 00:05:07,280 entire ticket but I think there might be one or two properties that are not quite similarly named here 84 00:05:08,900 --> 00:05:15,680 I think order I.D. has not quite lining up all I mean to say here is that we in many places throughout 85 00:05:15,680 --> 00:05:19,340 this course we could have just thrown in an entire model to publish functions and whatnot. 86 00:05:19,410 --> 00:05:22,250 But you'll notice that I have not really been doing that instead of been listing out all the different 87 00:05:22,250 --> 00:05:23,550 properties one by one. 88 00:05:23,630 --> 00:05:28,040 I personally like to list out all the properties just to make sure that I'm kind of using or picking 89 00:05:28,040 --> 00:05:31,110 everything appropriately off of the model. 90 00:05:31,140 --> 00:05:33,070 Just a quick side note OK. 91 00:05:33,090 --> 00:05:38,250 So for the I.T. we'll get our ticket i.e. for price. 92 00:05:38,250 --> 00:05:43,800 Ticket price or title ticket title. 93 00:05:44,010 --> 00:05:44,990 What else is there. 94 00:05:45,000 --> 00:05:46,140 We need our user I.D. 95 00:05:50,670 --> 00:05:51,300 order I.D. 96 00:05:55,050 --> 00:06:02,320 And I think that is about a version version. 97 00:06:02,340 --> 00:06:05,760 There we go again. 98 00:06:05,940 --> 00:06:06,860 So that looks good. 99 00:06:06,870 --> 00:06:11,050 We're now publishing our event and one other thing I ought to mention here. 100 00:06:11,060 --> 00:06:16,520 You'll recall that in the past we discussed that if we do not put the awake keyword right here we're 101 00:06:16,580 --> 00:06:20,960 kind of assuming that the entire publish action is just going to go through successfully. 102 00:06:20,960 --> 00:06:24,530 So we might want to make sure we put on the A WAIT RIGHT HERE BECAUSE THAT'S GONNA MAKE SURE THAT IF 103 00:06:24,530 --> 00:06:28,400 ANYTHING GOES WRONG WITH THE publish then we're gonna throw an error on this line of code and never 104 00:06:28,400 --> 00:06:33,740 go down to AK So that would probably be desirable in this case. 105 00:06:33,750 --> 00:06:34,020 OK. 106 00:06:34,080 --> 00:06:35,160 So let's say this. 107 00:06:35,160 --> 00:06:36,490 That's pretty much it. 108 00:06:36,630 --> 00:06:40,860 We'll take a quick pause right here and then hopefully do some kind of manual test or something similar 109 00:06:40,860 --> 00:06:41,640 in the next video.