1
00:00:01,819 --> 00:00:07,880
OK, let's move on to delete cell, which should be really easy now that we're using the library to

2
00:00:07,880 --> 00:00:12,740
remember delete so we can go and take a look at the action that we're going to receive in that particular

3
00:00:12,740 --> 00:00:13,120
case.

4
00:00:13,340 --> 00:00:18,140
So instead of my actions index thoughts file, here's a definition for delete cell action.

5
00:00:18,440 --> 00:00:20,660
So we're going to get a of property that is a string.

6
00:00:20,870 --> 00:00:25,550
And we had said very briefly that this payload was going to be the idea, the cell that we want to delete.

7
00:00:26,050 --> 00:00:29,840
We're going to try to find a cell with that particular ID and somehow delete it.

8
00:00:30,200 --> 00:00:35,270
Now, remember something that we discussed very briefly in the last video inside of our state being

9
00:00:35,270 --> 00:00:36,680
managed by this reducer.

10
00:00:36,830 --> 00:00:41,480
We've actually got two locations where this ID is going to be used and we need to make sure we remove

11
00:00:41,480 --> 00:00:43,070
that ID from both locations.

12
00:00:43,490 --> 00:00:47,870
So we have to go through the order array, which is going to be a array of strings, all the different

13
00:00:47,870 --> 00:00:49,010
IDs of our different cells.

14
00:00:49,280 --> 00:00:51,720
We need to find the appropriate ID and remove it.

15
00:00:52,280 --> 00:00:53,860
We also have to go through data.

16
00:00:53,870 --> 00:00:57,290
We have to find the appropriate cell inside there and delete that as well.

17
00:00:58,430 --> 00:01:02,870
Because we are making use of the IMR library, doing these updates is going to be pretty straightforward.

18
00:01:03,200 --> 00:01:09,230
I really recommend that you keep open that documentation page I just showed you the one that says update

19
00:01:09,230 --> 00:01:09,770
patterns.

20
00:01:10,040 --> 00:01:15,140
And this will tell you exactly how to do a variety of different updates to either objects or to arrays.

21
00:01:15,470 --> 00:01:20,210
In this case, we want to update an object and we want to update an array so we can very easily just

22
00:01:20,210 --> 00:01:24,380
take a look at the documentation and will tell us how to make these different updates.

23
00:01:25,810 --> 00:01:31,060
So first, in order to delete the cell out of our data object, we can do something like this right

24
00:01:31,060 --> 00:01:31,390
here.

25
00:01:31,940 --> 00:01:35,620
We're just going to call delete, look at our state object.

26
00:01:37,050 --> 00:01:42,090
And we're going to remove whatever that key is, so in this case, it's going to be our action Palit

27
00:01:42,120 --> 00:01:42,570
property.

28
00:01:43,480 --> 00:01:47,830
Let's take care of that first instead of delete cell, I'm no longer going to return state just because

29
00:01:47,830 --> 00:01:48,640
we do not have to.

30
00:01:49,750 --> 00:01:53,620
And we'll do a delete state that data.

31
00:01:54,710 --> 00:01:56,390
Action, not payload.

32
00:01:57,550 --> 00:01:58,210
And that's it.

33
00:02:00,080 --> 00:02:01,040
Then next up.

34
00:02:02,050 --> 00:02:07,060
We can go down to Arae mutation's and this will tell us how we can delete an element out of this array,

35
00:02:07,660 --> 00:02:10,630
notice that there is documentation here for delete by index.

36
00:02:10,810 --> 00:02:15,130
We don't actually know the index of this particular ID right now, so we're not going to use the Leapai

37
00:02:15,130 --> 00:02:15,610
index.

38
00:02:16,840 --> 00:02:17,860
Let's keep going down.

39
00:02:19,760 --> 00:02:26,300
And you will notice down here, they've got pretty much our exact use case, so we've got Dileep by

40
00:02:26,300 --> 00:02:26,800
IDX.

41
00:02:29,210 --> 00:02:33,340
We've got index, so they're going to find the index of the appropriate record that we want to delete

42
00:02:33,650 --> 00:02:35,360
and they call Splice to remove it.

43
00:02:37,640 --> 00:02:39,380
So we can do pretty much exactly that.

44
00:02:40,450 --> 00:02:45,560
We can't technically also do a filter operation as well, which in my opinion is just a little bit easier.

45
00:02:46,270 --> 00:02:50,590
So we're going to use the filter case just because it doesn't require these two separate lines of code.

46
00:02:51,060 --> 00:02:53,770
Let me show you how we would achieve this if we were using filter.

47
00:02:55,070 --> 00:02:58,610
So if you're going to do a filter, we could do state court order.

48
00:02:59,740 --> 00:03:02,620
I'll then do a state court order filter.

49
00:03:03,660 --> 00:03:05,490
We're going to take a look at each ID.

50
00:03:06,510 --> 00:03:13,170
And we want to return calls on the ID that we do not want to keep, so I'm going to do ID not equal

51
00:03:13,170 --> 00:03:15,270
to action that payload.

52
00:03:16,640 --> 00:03:18,330
Now we're going to create a brand new.

53
00:03:19,240 --> 00:03:21,940
Order and assign it back to state court order.

54
00:03:22,800 --> 00:03:23,780
And that's pretty much it.

55
00:03:25,620 --> 00:03:28,830
Now, we've handled delete cell and just two very small lines of code.

56
00:03:29,770 --> 00:03:34,210
OK, let's take a pause right here, now that we've handled this case, move on to our other two cases

57
00:03:34,210 --> 00:03:34,950
in just a moment.

