WEBVTT

1
00:00.920 --> 00:02.330
Hi everyone.

2
00:02.360 --> 00:07.550
Let me summarize the dependency injection techniques a little bit.

3
00:08.990 --> 00:12.650
Actually, the dependency injection is a design pattern.

4
00:13.310 --> 00:13.820
Okay.

5
00:14.150 --> 00:14.960
Now.

6
00:17.660 --> 00:32.540
When we mark the class will be injectable, and import it's inside the provider of the module.

7
00:33.980 --> 00:43.550
What's actually happened under the hood, it will create the something called IOC container.

8
00:44.030 --> 00:50.390
Inversion of control container or dependency injection container.

9
00:50.420 --> 00:51.800
This will be the same.

10
00:51.950 --> 00:52.520
Okay.

11
00:53.720 --> 00:55.490
But I think I will go.

12
00:55.520 --> 00:57.890
That will be the IOC container.

13
00:59.150 --> 01:03.500
And when we mark the object will be @Injectable.

14
01:03.500 --> 01:08.060
And import it inside the module providers.

15
01:09.200 --> 01:16.440
It will create the IOC container and pass the object into here.

16
01:17.670 --> 01:18.600
Test service

17
01:21.540 --> 01:21.930
Okay.

18
01:21.960 --> 01:23.040
And test repo

19
01:27.570 --> 01:28.140
Okay.

20
01:30.360 --> 01:43.710
And later, when the some controller wants to access into the test service, it will auto look up inside

21
01:43.710 --> 01:48.240
the IOC container and take the test service.

22
01:48.990 --> 01:49.560
Okay.

23
01:49.680 --> 01:55.530
And pass it inside the parameter of the constructor.

24
01:56.580 --> 02:00.360
You can see, it will pass it directly right here.

25
02:03.300 --> 02:04.350
Into the controller.

26
02:08.640 --> 02:14.700
And all of that are done by the.

27
02:15.300 --> 02:16.890
NestJS framework.

28
02:19.680 --> 02:20.010
Okay.

29
02:20.040 --> 02:21.690
Hopefully this makes sense right.

30
02:24.300 --> 02:27.000
Let me write a flow one more time.

31
02:27.750 --> 02:28.260
Firstly

32
02:28.260 --> 02:28.280
--

33
02:30.680 --> 02:32.000
Firstly, the controller.

34
02:33.710 --> 02:37.490
The controller is say: it has a dependency.

35
02:37.880 --> 02:38.360
Okay.

36
02:38.390 --> 02:39.080
The controller.

37
02:41.300 --> 02:45.140
The controller I have a dependency.

38
02:48.740 --> 02:59.720
And for that reason, it will look up into a IOC container.

39
03:02.210 --> 03:02.810
And.

40
03:06.890 --> 03:07.220
Say.

41
03:10.880 --> 03:15.620
In this case will be test service object creation.

42
03:15.980 --> 03:16.370
Okay.

43
03:16.400 --> 03:18.710
Test service object, not test service class.

44
03:18.740 --> 03:19.160
Okay.

45
03:19.190 --> 03:22.430
This is clearly the object creation.

46
03:23.000 --> 03:23.360
Okay.

47
03:23.510 --> 03:28.820
It will take test service object and pass it inside the controller.

48
03:29.750 --> 03:30.140
Okay.

49
03:31.160 --> 03:32.540
That's the how.

50
03:34.940 --> 03:36.350
Dependency injection work.

51
03:39.410 --> 03:41.600
Hope you understand this video.

52
03:41.630 --> 03:43.430
I will see you in the next one.