Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,360 --> 00:00:03,400
We're now going to move on to our common service.
2
00:00:03,430 --> 00:00:08,260
We need to make sure that any time someone creates new comment we once again emit an event over to that
3
00:00:08,260 --> 00:00:09,280
event bus.
4
00:00:09,280 --> 00:00:11,900
In this case our event is going to look a little something like this.
5
00:00:11,920 --> 00:00:17,070
They'll have a type of comic created and the data in this case will be the actual comment itself.
6
00:00:17,080 --> 00:00:21,940
So once again we're going to send this over to the event bus and the event bus is going to echo so to
7
00:00:21,940 --> 00:00:22,570
speak.
8
00:00:22,570 --> 00:00:27,680
This event over to all of our different services we're going to once again see that we're going to get
9
00:00:27,680 --> 00:00:33,020
a couple of forum for errors because again we don't have anything on the services themselves to receive
10
00:00:33,020 --> 00:00:35,000
these events just yet.
11
00:00:35,000 --> 00:00:35,260
All right.
12
00:00:35,280 --> 00:00:40,960
So going to change back over to my editor I'm going to find the comments service folder.
13
00:00:40,970 --> 00:00:42,380
Here it is right here.
14
00:00:42,380 --> 00:00:47,260
Inside there I'll open up the index such as file at the very top.
15
00:00:47,360 --> 00:00:48,320
I'll get access
16
00:00:51,400 --> 00:00:54,470
all then go down to my code where I'm creating a new comment.
17
00:00:54,520 --> 00:00:55,120
Here it is right here
18
00:00:58,040 --> 00:01:04,090
I'll then add in right after we add in that new comment right there or we push it into that.
19
00:01:04,230 --> 00:01:06,680
Right about right after that's really where we kind of save.
20
00:01:06,690 --> 00:01:08,290
So to speak the comments.
21
00:01:08,730 --> 00:01:19,620
I'll go ahead and we'll add in the axial stop post to local host colon four thousand and five flash
22
00:01:19,650 --> 00:01:26,970
events and once again the data or the event they were gonna send over is going to have a type of something
23
00:01:26,970 --> 00:01:34,660
like comment created and a data property that's gonna be the actual comment itself to remember a comment
24
00:01:34,840 --> 00:01:41,260
is going to have the comment tidy some content and then in that case or in this case that is the entire
25
00:01:41,260 --> 00:01:41,900
comment.
26
00:01:41,920 --> 00:01:48,310
Well we're going to also add into this data property another property of post I.D. just to clarify exactly
27
00:01:48,310 --> 00:01:52,020
what comment this thing is tied to in this case for data.
28
00:01:52,040 --> 00:02:02,870
I'm going to put in the I.D. of comment I.D. the content and then finally our post I.D. as well which
29
00:02:02,870 --> 00:02:04,690
is available inside this request handler.
30
00:02:04,700 --> 00:02:09,240
Remember it's technically in that parameter string right there or the root string.
31
00:02:09,320 --> 00:02:18,110
So we can access that using rec perhaps dot I.D. We'll say post I.D. is rec not prams dot I.D. then
32
00:02:18,110 --> 00:02:24,850
once again I'm going to add on async to the wrapping function and awaits on the request itself.
33
00:02:27,090 --> 00:02:27,440
OK.
34
00:02:27,540 --> 00:02:28,750
ALEX Good.
35
00:02:28,760 --> 00:02:30,360
So let's test this out again.
36
00:02:30,450 --> 00:02:35,350
I'm going to flip on over to my browser to find the post we had just created.
37
00:02:35,350 --> 00:02:41,950
And I'll add in some comments and submit it's I can refresh the page see some comments here.
38
00:02:42,110 --> 00:02:46,670
And then finally I'll go over to my terminal and I'm going to expect to once again see a series of 4
39
00:02:46,670 --> 00:02:49,590
4 errors coming out of our event bus.
40
00:02:49,610 --> 00:02:53,870
Again that's because we don't have anything inside of our services yet to actually receive these events
41
00:02:55,240 --> 00:02:55,490
yet.
42
00:02:55,500 --> 00:02:56,040
That looks good.
43
00:02:57,320 --> 00:03:02,570
Well at this point time we've now got two services that are emitting events whenever something interesting
44
00:03:02,570 --> 00:03:03,630
happens.
45
00:03:03,630 --> 00:03:08,360
So now we need to make sure that all of our services right now really just posting comments because
46
00:03:08,360 --> 00:03:13,580
we've not yet created the query service as an endpoint where it can receive these events and then do
47
00:03:13,580 --> 00:03:14,590
some processing on them.
48
00:03:14,810 --> 00:03:19,730
If that service cares about the event that was just emitted in our scenario or in our case right now
49
00:03:20,120 --> 00:03:24,380
our postal service and the common service don't really care whatsoever.
50
00:03:24,380 --> 00:03:28,910
They just don't care about any incoming events out of the two that we've created common created and
51
00:03:28,910 --> 00:03:30,020
post created.
52
00:03:30,020 --> 00:03:33,920
But as soon as we make this query service Well we're definitely going to have something that is very
53
00:03:33,920 --> 00:03:39,380
much interested in some events that are coming out of our application so quick pause right here.
54
00:03:39,380 --> 00:03:44,450
We're going to start putting this and this those two event person who wrote handlers together in just
55
00:03:44,450 --> 00:03:44,780
a moment.
5653
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.