Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,270 --> 00:00:06,030
In this lecture, we're going to refactor our configuration of FIREBASE by exporting services.
2
00:00:06,300 --> 00:00:09,410
We're going to be using additional services by Firebase.
3
00:00:09,780 --> 00:00:13,260
We're already using one service, which is the authentication service.
4
00:00:13,590 --> 00:00:18,480
The authentication service by Firebase does not store additional information about the user.
5
00:00:18,900 --> 00:00:20,750
It stores the email and password.
6
00:00:20,910 --> 00:00:21,760
That's about it.
7
00:00:21,900 --> 00:00:25,310
We aren't able to store their age, country or name.
8
00:00:25,860 --> 00:00:28,860
We won't be able to store it in the authentication service.
9
00:00:29,010 --> 00:00:34,320
If we like to store additional information about the user will need to store it in the database.
10
00:00:34,650 --> 00:00:37,620
Firebase has another service called Firestar.
11
00:00:37,890 --> 00:00:39,990
It's the name of their official database.
12
00:00:40,320 --> 00:00:45,450
The FIREBASE SDK comes with a module for interacting with the fire store API.
13
00:00:45,870 --> 00:00:50,580
The functions for interacting with the database can be enabled by importing the package.
14
00:00:53,110 --> 00:00:56,440
We're going to open the firebase file in our editor.
15
00:00:56,770 --> 00:01:00,130
Every service by Firebase is broken up into packages.
16
00:01:00,400 --> 00:01:04,959
We've imported the authentication package to enable the methods for authentication.
17
00:01:05,349 --> 00:01:11,230
If we like to enable the methods for interacting with the database, we'll need to import the fire store
18
00:01:11,240 --> 00:01:11,950
package.
19
00:01:12,250 --> 00:01:15,070
We'll import it without assigning it a variable.
20
00:01:17,740 --> 00:01:24,010
It's crucial we import the firestorm package and not the database package, if you were to read the
21
00:01:24,010 --> 00:01:27,790
documentation, you might come across the database package.
22
00:01:28,270 --> 00:01:31,850
The database package is for the real time database service.
23
00:01:31,990 --> 00:01:34,690
It's a package for the old version of the database.
24
00:01:34,840 --> 00:01:39,070
For this course, we're using Firestar, which is the newer database.
25
00:01:39,340 --> 00:01:44,800
Importing the fire store package, will assure us that we have the correct methods and properties for
26
00:01:44,800 --> 00:01:46,850
interacting with the correct database.
27
00:01:47,260 --> 00:01:52,390
We don't have to import the database package because we're not using the real time database.
28
00:01:52,910 --> 00:01:55,870
It's not required to assign the package to a variable.
29
00:01:56,170 --> 00:01:59,370
Firebase will extend the firebase object.
30
00:01:59,950 --> 00:02:02,080
The next step is to refactor the code.
31
00:02:02,330 --> 00:02:05,800
I'm going to switch over to the register form component.
32
00:02:08,289 --> 00:02:15,010
In the register function, we're invoking the firebase stop function to access the authentication service
33
00:02:15,010 --> 00:02:19,840
by Firebase will have to repeatedly call the firebase off function.
34
00:02:19,840 --> 00:02:24,060
If we want to use the authentication service, that's not very efficient.
35
00:02:24,400 --> 00:02:27,640
It would be better if we created a reference to the service.
36
00:02:27,970 --> 00:02:30,100
We'll want to do the same for Firestar.
37
00:02:30,400 --> 00:02:33,580
We're going to use the database frequently throughout this course.
38
00:02:33,880 --> 00:02:36,940
Creating a reference will make our code more readable.
39
00:02:37,390 --> 00:02:39,520
Switch back to the Firebase File.
40
00:02:39,730 --> 00:02:44,410
We're going to create references to the authentication and firestorm services.
41
00:02:44,650 --> 00:02:46,890
Then we'll export the references.
42
00:02:47,200 --> 00:02:53,560
This will allow for any component to access a service without having to create a reference itself will
43
00:02:53,560 --> 00:02:56,980
begin by removing the export default keywords.
44
00:02:59,290 --> 00:03:05,800
Instead of exporting a default object, we're going to use named exports, we'll still want to initialize
45
00:03:05,800 --> 00:03:08,630
Firebase with the initialize app function.
46
00:03:08,980 --> 00:03:10,210
This will not change.
47
00:03:10,420 --> 00:03:15,940
After initializing the app, we're going to create a variable called authentication.
48
00:03:16,300 --> 00:03:21,580
Its value will be set to the object returned by the firebase function.
49
00:03:24,170 --> 00:03:30,170
Create another variable for the database reference, its value will be set to the object returned by
50
00:03:30,170 --> 00:03:32,780
the Firebase Firestar function.
51
00:03:35,370 --> 00:03:41,280
The firestorm function will return an object with methods and properties for interacting with the database
52
00:03:41,640 --> 00:03:45,150
rather than repeatedly calling it, will store it in a variable.
53
00:03:45,420 --> 00:03:47,360
This will make our code more readable.
54
00:03:47,640 --> 00:03:51,360
We're finished creating the references we'll want to explore with them.
55
00:03:51,690 --> 00:03:55,500
Both variables will be exported as named exports.
56
00:03:58,020 --> 00:04:02,830
We're using named exports because it's easier to structure in an import statement.
57
00:04:03,180 --> 00:04:08,820
This will break the app because the register form component is expecting the firebase object when it's
58
00:04:08,820 --> 00:04:10,420
not being exported anymore.
59
00:04:10,770 --> 00:04:17,279
We'll need to update the component, switch over to the register form component, scroll to the import
60
00:04:17,279 --> 00:04:24,240
statements, update the import statement for the firebase file the of the object for the authentication
61
00:04:24,240 --> 00:04:24,720
reference.
62
00:04:24,720 --> 00:04:25,530
We export it.
63
00:04:28,060 --> 00:04:35,470
We'll update the register function next, instead of calling the firebase afunction directly, we can
64
00:04:35,470 --> 00:04:38,680
replace this line with the off reference we imported.
65
00:04:41,250 --> 00:04:47,880
Great, we've successfully refactored our code base, we are creating references of our services, this
66
00:04:47,880 --> 00:04:53,610
makes our code more readable, will continue with storing the user's information in the next lecture.
6798
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.