1 00:00:00,930 --> 00:00:03,800 The ticket created publisher is definitely now working. 2 00:00:03,820 --> 00:00:07,290 So now we're going to go through this very similar process and we're gonna create a new publisher to 3 00:00:07,290 --> 00:00:08,140 handle ticket. 4 00:00:08,160 --> 00:00:09,890 Tickets being updated as well. 5 00:00:10,680 --> 00:00:14,730 So again the very person we have to do is go into our events publishers directory. 6 00:00:14,730 --> 00:00:20,920 We're gonna create a new file inside they're called Ticket updated publisher dot T.S. we could write 7 00:00:20,920 --> 00:00:25,750 out all the code from this from scratch or alternatively we could just do a copy paste from ticket created 8 00:00:25,750 --> 00:00:30,730 publisher lets us do the ticket or the copy paste just to save ourselves a little bit of time so go 9 00:00:30,730 --> 00:00:36,380 to ticket created copy everything inside of you or go backward updated and paste and then inside of 10 00:00:36,380 --> 00:00:46,320 here we'll go round and update the word created to updated instead so I'll do one update second update. 11 00:00:48,790 --> 00:00:49,510 Third update 12 00:00:56,350 --> 00:01:01,330 and fifth so we should not see the word created anywhere inside of here. 13 00:01:01,330 --> 00:01:06,230 We should have five copies of updated ok once that's all done. 14 00:01:06,260 --> 00:01:13,850 We'll save this and then going to go over to my roots directory I'll find the update handler so inside 15 00:01:13,850 --> 00:01:25,600 of here we will import ticket updated publisher from up one directory events publishers ticket updated 16 00:01:25,610 --> 00:01:26,100 publisher 17 00:01:30,340 --> 00:01:33,010 and then we also need our client wrapper as well. 18 00:01:34,360 --> 00:01:40,110 So we'll get Nat's wrapper from up Nat's wrapper 19 00:01:44,070 --> 00:01:49,620 then down inside of our update handler right after we successfully do the save right after that that's 20 00:01:49,620 --> 00:01:56,430 when we probably want to make sure that we met some kind of update event so we can do a new ticket updated 21 00:01:56,500 --> 00:02:06,690 publisher we'll pass in our Nat's wrapper clients and we'll call publish and then typescript remember 22 00:02:06,690 --> 00:02:09,790 is going to guide us on the different properties we need to add inside of here. 23 00:02:09,870 --> 00:02:13,380 So we need to put in the idea that ticket title price and user I.D.. 24 00:02:13,440 --> 00:02:16,470 Once again the ideal the ticket. 25 00:02:16,520 --> 00:02:20,500 Dot I.D. title is ticket. 26 00:02:20,500 --> 00:02:21,010 Title 27 00:02:23,510 --> 00:02:29,460 price and user I.D. and that should be at 28 00:02:33,540 --> 00:02:36,210 let's save this we'll do a quick test of this as well. 29 00:02:36,210 --> 00:02:38,910 So we don't really have anything to listen for this event. 30 00:02:38,910 --> 00:02:44,220 I just want to make sure that we can send in a post or is me a put to update a given ticket go over 31 00:02:44,220 --> 00:02:48,030 to our terminal and just verify makes sure we don't see any errors or anything like that coming out 32 00:02:48,030 --> 00:02:50,230 of our ticket service. 33 00:02:50,280 --> 00:02:56,760 So to do in updates are going to change my request type here to put I'm going to take the idea of the 34 00:02:56,790 --> 00:03:03,480 ticket I just created in the last video and I'll add it onto the very end of that year El and then I'll 35 00:03:03,480 --> 00:03:08,590 make a change to the price change it to say 10 so I'll send this off. 36 00:03:09,340 --> 00:03:09,730 OK. 37 00:03:09,730 --> 00:03:11,670 Looks like the update was successful. 38 00:03:11,690 --> 00:03:13,080 I'll then go back over to my terminal. 39 00:03:13,090 --> 00:03:18,840 I'll find scaffold and I should see event published to subject ticket colon update right there. 40 00:03:18,850 --> 00:03:20,980 Which means that the event was successfully published. 41 00:03:22,050 --> 00:03:24,750 Let's say it looks pretty good all right. 42 00:03:25,510 --> 00:03:28,120 So everything at this point definitely works. 43 00:03:28,120 --> 00:03:31,270 What we have right here it is a working implementation. 44 00:03:31,270 --> 00:03:33,970 There are nonetheless one or two quick things I wanna mention. 45 00:03:33,970 --> 00:03:38,030 One is something for your own benefit for projects you might work on on the future. 46 00:03:38,140 --> 00:03:39,900 Just something to kind of get your mind running. 47 00:03:40,150 --> 00:03:44,980 And the other is just something I want to mention around how it's kind of awkward right now to actually 48 00:03:44,980 --> 00:03:46,090 publish an event. 49 00:03:46,090 --> 00:03:50,410 So we have to create a new instance of the publisher we have to pass on the client and as kind of a 50 00:03:50,410 --> 00:03:57,370 side effect of all this I want to also mention that if we open up yet another terminal window and go 51 00:03:57,370 --> 00:03:59,910 into our ticket service and try to run our tests. 52 00:03:59,950 --> 00:04:01,280 So NPM run tests. 53 00:04:01,330 --> 00:04:06,610 We're probably gonna see all this stuff failing horribly because whenever we tried to test say the update 54 00:04:06,670 --> 00:04:14,950 or new operations we don't actually have any running connection to nets and so we're gonna see a ton 55 00:04:14,950 --> 00:04:18,190 of stuff inside here cannot access Nats client before connecting. 56 00:04:18,430 --> 00:04:22,180 And so without doubt there's kind of a little bit of awkwardness around how we're actually publishing 57 00:04:22,180 --> 00:04:23,470 events right now. 58 00:04:23,470 --> 00:04:24,660 So quick pause right here. 59 00:04:24,730 --> 00:04:26,590 Go over some of the site topics in just a moment.