1 00:00:01,460 --> 00:00:05,450 Now that we've got that subjects in on put together we're going to put together a interface that is 2 00:00:05,450 --> 00:00:10,460 going to describe the very distinct coupling between this particular subject and the event data that 3 00:00:10,460 --> 00:00:12,250 we expect to receive with it. 4 00:00:12,260 --> 00:00:15,920 So back inside my editor once again inside the events directory. 5 00:00:15,920 --> 00:00:24,190 I'm going to make a new file called Ticket created event dot t yes at the very top we're going to import 6 00:00:24,190 --> 00:00:35,750 that into we just created so subjects from subjects we're then going to create an export and interface 7 00:00:36,320 --> 00:00:39,840 that we're going to call ticket created events. 8 00:00:39,860 --> 00:00:42,680 So again this is where we're going to set up this very tight coupling. 9 00:00:42,680 --> 00:00:47,060 We're going to say that there is going to be a very tight coupling between this very specific subject 10 00:00:47,060 --> 00:00:49,190 name and this structure of data. 11 00:00:49,200 --> 00:00:54,850 We went to then figure out how to enforce that coupling inside of our actual listener so inside this 12 00:00:54,850 --> 00:01:00,760 interface we're gonna say that we expect there to be an event at some point time that indicates that 13 00:01:00,760 --> 00:01:08,650 a ticket was just created the subject for this event will be of type subject start to get created and 14 00:01:08,650 --> 00:01:15,260 the data that we expect to see inside that event is going to be an idea that is a string a title that 15 00:01:15,260 --> 00:01:19,980 is a string any price that is a number. 16 00:01:19,990 --> 00:01:23,950 So again this is where we set up the coupling between this very specific subject and this structure 17 00:01:23,950 --> 00:01:29,260 of data we're going to eventually create interfaces just like the one right here to describe all the 18 00:01:29,260 --> 00:01:32,950 different types of events we eventually expect to have inside our application. 19 00:01:32,950 --> 00:01:39,640 So for example we might have a ticket updated event a order created order cancels order whatever else 20 00:01:39,850 --> 00:01:45,520 may we have a payment success event or payment failed event every different event we ever expect to 21 00:01:45,520 --> 00:01:46,840 have inside our application. 22 00:01:46,840 --> 00:01:48,880 We're going to create a different interface for it. 23 00:01:48,910 --> 00:01:53,410 And again that's going to make sure that typescript can step in and make sure that we have some matching 24 00:01:53,440 --> 00:01:56,920 subject and data inside of one of our custom listeners. 25 00:01:56,920 --> 00:01:59,160 We put together OK. 26 00:01:59,190 --> 00:02:02,430 So we've now got the listing of all the possible subjects. 27 00:02:02,430 --> 00:02:06,570 We've got the interface that describes the coupling of one particular subject with the structure of 28 00:02:06,570 --> 00:02:07,230 data. 29 00:02:07,230 --> 00:02:12,570 Now last thing we have to do is teach typescript how to somehow do some verification and make sure that 30 00:02:12,570 --> 00:02:17,400 when we put our custom listener together like this one right here we need to make sure that typescript 31 00:02:17,430 --> 00:02:22,020 understands that needs to check and make sure that this subject right here matches up with the type 32 00:02:22,080 --> 00:02:24,360 of data argument we have right there. 33 00:02:24,360 --> 00:02:25,920 So we'll take care of that in the next video.