1
00:00:00,260 --> 00:00:01,040
Hello, guys.

2
00:00:01,040 --> 00:00:02,000
Good to see you back.

3
00:00:02,000 --> 00:00:05,030
This is the another part of this module tutorial.

4
00:00:05,450 --> 00:00:11,450
And today in this tutorial we are going to learn default function module came with a default function.

5
00:00:11,450 --> 00:00:13,940
So let's see how we can create this function.

6
00:00:13,940 --> 00:00:16,130
Also we are going to see how we can use it.

7
00:00:16,130 --> 00:00:18,890
So let's back to the library dot js file.

8
00:00:19,340 --> 00:00:21,710
First I'm going to comment out all of this code.

9
00:00:22,190 --> 00:00:24,800
And then I'm going to create default function.

10
00:00:24,800 --> 00:00:34,670
To create default function we need to use default keyword default default function, then parenthesis.

11
00:00:34,700 --> 00:00:36,320
Then inside the round braces.

12
00:00:36,350 --> 00:00:41,120
This default function basically represents the whole file with that.

13
00:00:41,120 --> 00:00:43,160
Also I want to export this function.

14
00:00:43,160 --> 00:00:45,500
So here I'm going to type export keyword.

15
00:00:47,750 --> 00:00:48,380
Export.

16
00:00:49,130 --> 00:00:51,650
And here I'm going to type something.

17
00:00:51,950 --> 00:00:59,530
So type console dot log inside the round braces inside the double quotes.

18
00:00:59,540 --> 00:01:03,860
Hello and semicolon too in this line.

19
00:01:04,100 --> 00:01:07,220
Now let's back to the main dot js file.

20
00:01:07,490 --> 00:01:14,240
Also I'm going to comment out all of this code and I'm going to duplicate this line and comment out

21
00:01:14,240 --> 00:01:15,230
previous one.

22
00:01:16,810 --> 00:01:20,290
And to import default function, you need to use the same process.

23
00:01:20,320 --> 00:01:21,400
Let me show you how.

24
00:01:21,940 --> 00:01:23,470
So I'm going to remove this star sign.

25
00:01:23,470 --> 00:01:28,510
And as and inside the curly braces I'm going to pass the function name which is default.

26
00:01:28,630 --> 00:01:29,660
Default.

27
00:01:29,770 --> 00:01:32,830
Also you need to take alias name as de.

28
00:01:34,160 --> 00:01:34,820
That's it.

29
00:01:35,300 --> 00:01:37,250
And now we can call this function.

30
00:01:37,610 --> 00:01:42,380
So here I'm going to type D and semicolon two in this line after save this file.

31
00:01:42,380 --> 00:01:45,170
As you can see in my browser it's written hello.

32
00:01:45,620 --> 00:01:49,520
We don't need to take any name for this function whenever we call this function.

33
00:01:49,520 --> 00:01:51,020
Otherwise import this function.

34
00:01:51,020 --> 00:01:53,270
We take this name for this function.

35
00:01:53,910 --> 00:01:57,930
Now, at last I am going to introduce you another feature of module.

36
00:01:58,780 --> 00:02:01,210
Which is known as aggregate module.

37
00:02:01,540 --> 00:02:05,380
Here we are going to learn how we can use multiple module in a file.

38
00:02:05,770 --> 00:02:08,740
So at first I'm going to comment out this line.

39
00:02:09,310 --> 00:02:13,630
Then I'm going to uncomment this import line.

40
00:02:13,870 --> 00:02:17,770
With that let's back to the language's file.

41
00:02:18,010 --> 00:02:20,300
And from library dot js file.

42
00:02:20,320 --> 00:02:21,910
First I'm going to comment out this line.

43
00:02:21,910 --> 00:02:23,530
I don't need this line for now.

44
00:02:23,530 --> 00:02:26,290
And also I'm going to uncomment this export line.

45
00:02:26,620 --> 00:02:31,720
I want to export only user function nothing else.

46
00:02:31,750 --> 00:02:35,530
With that we need to uncomment this user function.

47
00:02:35,680 --> 00:02:36,640
That's it.

48
00:02:36,850 --> 00:02:39,550
Also I'm not going to pass any argument.

49
00:02:39,550 --> 00:02:41,490
So I remove this arguments.

50
00:02:41,500 --> 00:02:45,610
And here I'm going to type simply a text hello world.

51
00:02:49,480 --> 00:02:51,040
And I'm going to save this file.

52
00:02:51,740 --> 00:02:55,280
So in this library function we have only one function named user.

53
00:02:55,490 --> 00:03:00,260
And if you notice you can see we have another file mediator dot js.

54
00:03:00,880 --> 00:03:02,920
So let's jump into this file.

55
00:03:03,550 --> 00:03:08,950
This file going to play the role of a bridge between these two file main.js and library JS.

56
00:03:09,490 --> 00:03:17,110
And for your better understand I'm going to move this file between this library and main JS in our library

57
00:03:17,110 --> 00:03:18,080
dot js file.

58
00:03:18,100 --> 00:03:20,140
Here we export user function.

59
00:03:20,470 --> 00:03:23,020
And here I use the main js file.

60
00:03:23,530 --> 00:03:27,520
And in our HTML file we include the main dot js file.

61
00:03:27,970 --> 00:03:30,340
But in Maine dot js file.

62
00:03:30,700 --> 00:03:34,720
Here I'm going to change the import file path this time.

63
00:03:34,900 --> 00:03:37,840
So I'm going to duplicate this line and comment out previous one.

64
00:03:37,870 --> 00:03:41,980
This time I want to import mediator dot js.

65
00:03:42,430 --> 00:03:47,320
So here I'm going to type mediator dot js file.

66
00:03:47,740 --> 00:03:50,680
And I want to import the particular user function.

67
00:03:50,680 --> 00:03:53,710
So here I'm going to remove the name and start sign.

68
00:03:53,710 --> 00:03:57,280
And inside the curly braces I'm going to type user.

69
00:03:57,430 --> 00:04:03,310
Now the question is we do not create user function in mediator dot js file.

70
00:04:03,640 --> 00:04:09,380
So in the mediator dot js file I'm going to import the function from library dot js file.

71
00:04:09,400 --> 00:04:12,730
So I'm going to type import inside the round.

72
00:04:12,880 --> 00:04:14,380
Inside the curly braces.

73
00:04:14,410 --> 00:04:19,450
Our function name user from library dot js file.

74
00:04:19,630 --> 00:04:22,720
Library dot js.

75
00:04:23,110 --> 00:04:24,220
And I'm going to save this file.

76
00:04:24,310 --> 00:04:30,250
So in our mediator file we import the user function from live dot js.

77
00:04:30,460 --> 00:04:36,310
Then in our main dot js file we import the user function from mediator dot js file.

78
00:04:36,760 --> 00:04:41,140
But if I save this files it's going to return an error something like that.

79
00:04:41,170 --> 00:04:43,120
It is a syntax error.

80
00:04:43,510 --> 00:04:45,040
Here it print media.

81
00:04:45,370 --> 00:04:51,100
JS does not provide an export named user to resolve this problem.

82
00:04:51,100 --> 00:04:57,550
If we want to use any breeze file for that here we need to use export keyword.

83
00:04:57,550 --> 00:05:00,250
So I duplicate this line and comment out previous one.

84
00:05:00,250 --> 00:05:02,560
And here we need to type export.

85
00:05:03,550 --> 00:05:08,860
Now if I save this file now you can see there is no error in my console.

86
00:05:09,040 --> 00:05:17,530
So in our main dot js file if I call user function and remove the argument because this time I do not

87
00:05:17,560 --> 00:05:20,850
handle any argument in our user function and save this file.

88
00:05:20,860 --> 00:05:21,940
You can see the result.

89
00:05:21,970 --> 00:05:23,950
Now it's print hello world!

90
00:05:24,100 --> 00:05:26,770
So at first we export from library to mediator.

91
00:05:26,890 --> 00:05:30,790
Then from the mediator we export Main.js file.

92
00:05:30,910 --> 00:05:33,210
So this is it for this tutorial.

93
00:05:33,220 --> 00:05:36,880
In the next tutorial we are going to learn about promises.

94
00:05:37,150 --> 00:05:39,010
So thanks for watching this video.

95
00:05:39,010 --> 00:05:40,780
Stay tuned for the next tutorial.
