1 00:00:00,330 --> 00:00:02,650 Now, let me show you something very, very cool. 2 00:00:03,030 --> 00:00:10,390 We're going to insert some dummy data into our database and this dummy data is in the format of Jason. 3 00:00:11,010 --> 00:00:16,620 So if we head over to our real time database and yours won't look like this, yours will say, would 4 00:00:16,620 --> 00:00:17,930 you like to create a database? 5 00:00:17,940 --> 00:00:19,950 Go ahead and say yes. 6 00:00:19,950 --> 00:00:22,530 If if you want to do this section, you don't have to do this section. 7 00:00:22,540 --> 00:00:24,750 I'm just showing you that everything's working. 8 00:00:25,650 --> 00:00:26,370 Go ahead and click. 9 00:00:26,370 --> 00:00:26,730 Yes. 10 00:00:27,060 --> 00:00:29,030 And then allow access for 30 days. 11 00:00:29,370 --> 00:00:33,330 That just gets rid of the rules until we've actually developed something. 12 00:00:34,160 --> 00:00:40,680 OK, if you want to do this, you will have to create your own Jason data structure to do this. 13 00:00:40,690 --> 00:00:44,070 So I'm not actually going to give you the Jason for that. 14 00:00:44,100 --> 00:00:45,330 This is just a demonstration. 15 00:00:46,260 --> 00:00:52,470 So what I'm going to do here is import this, Jason, and before I do notice, there is nothing in our 16 00:00:52,470 --> 00:00:52,880 app. 17 00:00:53,040 --> 00:00:53,570 Right. 18 00:00:54,120 --> 00:00:58,000 But what I'm about to do is add a whole bunch of Jason. 19 00:00:58,530 --> 00:01:00,570 So here's my export, Jason. 20 00:01:00,870 --> 00:01:08,410 If I double click this and I hit import and when I do that, I'm going to quickly change to the app. 21 00:01:08,480 --> 00:01:08,970 There you go. 22 00:01:09,960 --> 00:01:13,310 So that proves that Firebase is listening. 23 00:01:13,650 --> 00:01:19,410 And when it gets that new data, it informs everyone that is making use of the data that it needs to 24 00:01:19,410 --> 00:01:26,520 do something now, which in our particular case was to display that particular data. 25 00:01:27,210 --> 00:01:29,100 So that's the real time demo. 26 00:01:29,430 --> 00:01:32,950 And just to recap the section, because it's quite a complex set up. 27 00:01:33,600 --> 00:01:35,490 First of all, you have to set up the firebase. 28 00:01:35,970 --> 00:01:43,530 Most importantly, you need to add an observer to that data base reference the child of messages looks 29 00:01:43,530 --> 00:01:44,970 like this. 30 00:01:46,130 --> 00:01:48,110 So we have all these objects in messages. 31 00:01:50,810 --> 00:01:56,330 Which are the individual messages with an ID that Firebase gives them automatically and of course, 32 00:01:56,330 --> 00:02:04,430 you can see date time and text in their messages is the child that's referenced inside of this observer. 33 00:02:04,680 --> 00:02:06,210 OK, so that's what we're listening to. 34 00:02:06,560 --> 00:02:11,530 We're not actually listening to the whole database, although you can do that if you wish. 35 00:02:11,540 --> 00:02:13,340 But I would advise that you don't. 36 00:02:13,670 --> 00:02:14,870 You split your app up. 37 00:02:14,870 --> 00:02:21,200 Logically speaking, once you've got that data, every time you get a new one, because we're looking 38 00:02:21,200 --> 00:02:28,040 at the child added, we're going to insert a row and scroll to that row, as well as append to our messages, 39 00:02:28,040 --> 00:02:35,210 data snapshot, because our table isn't listening to the live version of these messages. 40 00:02:35,360 --> 00:02:37,580 So we have to do this insert manually. 41 00:02:37,850 --> 00:02:44,810 Now, if you are on Android, you could tap into the room database, live observer, and that would 42 00:02:44,810 --> 00:02:46,520 do all of this automatically. 43 00:02:46,520 --> 00:02:53,120 So all you would need for Android is that line and potentially the scrolling line, depending on how 44 00:02:53,120 --> 00:02:59,410 you want it to behave, you wouldn't need to do any magic around inserting rows, OK? 45 00:02:59,450 --> 00:03:05,570 And then once we've got that, it's going to go ahead and insert the new row according to our cell phone 46 00:03:05,930 --> 00:03:06,260 app. 47 00:03:06,530 --> 00:03:13,370 So that is how we insert or rather how we listen to data from Firebase and how we insert adjacent file, 48 00:03:13,670 --> 00:03:15,050 if you so wish to do that.