1
00:00:00,930 --> 00:00:05,280
The last thing we need to do is apply a better type to our payload property right here for action than

2
00:00:05,280 --> 00:00:09,180
any, because, again, as much as possible, we want to avoid in any annotation.

3
00:00:09,780 --> 00:00:13,170
So to do so, we're going to make a couple of key factors inside this file.

4
00:00:13,410 --> 00:00:17,700
And I got to be totally honest with you, this is going to be probably the most challenging and confusing

5
00:00:17,700 --> 00:00:21,060
part of understanding how to get Redox entire script to work together.

6
00:00:21,480 --> 00:00:25,350
We're going to take a look at a diagram or two and really understand what it is we need to inside this

7
00:00:25,350 --> 00:00:27,990
file to get a better right here for our payload.

8
00:00:29,020 --> 00:00:34,000
OK, so first thing I want to really clarify is that we have our repositories reducer and inside of

9
00:00:34,000 --> 00:00:38,680
our application right now, there are three kinds of actions that we expect to receive.

10
00:00:39,280 --> 00:00:42,310
The first kind of action we expect to receive is going to look like this.

11
00:00:42,350 --> 00:00:46,410
There will be some kind of object that has a type property that is search repositories.

12
00:00:46,870 --> 00:00:49,030
We are currently handling that case right here.

13
00:00:50,530 --> 00:00:55,990
We might refer to that as our search repositories action, the second kind of action we have to process

14
00:00:55,990 --> 00:01:00,820
it was whenever we get a response back from the NPM API, we're kind of calling that action the search

15
00:01:00,820 --> 00:01:02,530
repositories success action.

16
00:01:02,890 --> 00:01:03,770
And it will be an action.

17
00:01:03,850 --> 00:01:04,489
Looks like this.

18
00:01:04,510 --> 00:01:09,850
So, again, an object that has a type of search repository success and then a payload property as an

19
00:01:09,850 --> 00:01:10,660
array of strings.

20
00:01:11,350 --> 00:01:13,120
And we're handling that case right there.

21
00:01:14,300 --> 00:01:19,510
Then finally, we have search repositories, air that's going to have a type of search repository there,

22
00:01:19,520 --> 00:01:23,750
and then the air that is a string and as you guess, yep, we're handling that exactly right there.

23
00:01:25,130 --> 00:01:30,710
So to better describe these different kinds of actions that are flowing into our reducer, we're going

24
00:01:30,710 --> 00:01:35,060
to create a separate interface to describe each kind of action.

25
00:01:35,570 --> 00:01:40,910
We're going to create one interface to describe this kind of action, another interface for this one

26
00:01:40,910 --> 00:01:42,560
and another interface for this one.

27
00:01:43,250 --> 00:01:46,550
These three interfaces might look a little something like this.

28
00:01:47,390 --> 00:01:48,980
So this is pretty much the same diagram.

29
00:01:48,980 --> 00:01:50,110
I just put it on its side.

30
00:01:50,150 --> 00:01:54,200
We still have search repositories, search repository, success in the air right there.

31
00:01:55,210 --> 00:01:59,410
So for each of these three different kinds of actions, we're going to write out interfaces that look

32
00:01:59,410 --> 00:02:06,400
like this, the first interface is going to say that all actions that are supposed to be search repositories,

33
00:02:06,400 --> 00:02:10,780
actions will always be an object that has a type property.

34
00:02:11,320 --> 00:02:15,790
And that type property is always going to be exactly the string search repositories.

35
00:02:16,300 --> 00:02:18,450
So, again, this is an interface definition right here.

36
00:02:18,670 --> 00:02:21,250
This is not an actual object we're going to write out in our code.

37
00:02:21,250 --> 00:02:22,810
It is going to be an interface.

38
00:02:23,890 --> 00:02:28,840
Then if we were to write out an interface describing the search repository success action, we would

39
00:02:28,840 --> 00:02:30,450
write out an interface that looks like this.

40
00:02:30,760 --> 00:02:32,620
It is an object that has a type property.

41
00:02:33,010 --> 00:02:36,340
There's going to be exactly the string search repositories success.

42
00:02:37,060 --> 00:02:39,100
It's going have a payload that is an array of strings.

43
00:02:39,250 --> 00:02:41,650
And then finally, something very similar down here as well.

44
00:02:42,620 --> 00:02:47,570
So let's go back over to our file, we're going to write out these three exact interfaces and we'll

45
00:02:47,570 --> 00:02:50,180
see how this really helps us out inside of a reducer.

46
00:02:51,690 --> 00:02:56,100
OK, so a little bit of typing we have to do here, I'm going to first begin by deleting the existing

47
00:02:56,100 --> 00:02:56,960
interface we have.

48
00:02:57,630 --> 00:03:01,560
I'm going to write out interface search repositories.

49
00:03:04,400 --> 00:03:10,490
And I'm going to say that in order for some object to satisfy this interface, it must have a tight

50
00:03:10,500 --> 00:03:15,950
property that is exactly equal to the string Zorch repositories.

51
00:03:18,160 --> 00:03:24,070
Our next one is going to be an interface for search repositories, success, action.

52
00:03:25,260 --> 00:03:31,200
I'm going to say that in order to have an object that satisfies this interface, it must have a type.

53
00:03:32,220 --> 00:03:34,200
That is exactly the strain search.

54
00:03:35,480 --> 00:03:36,470
Repositories.

55
00:03:38,000 --> 00:03:42,230
Success, it must also have a payload that is an array of strings.

56
00:03:43,280 --> 00:03:44,000
And then finally.

57
00:03:44,910 --> 00:03:51,890
Zorch repositories air action in order for an object to satisfy this interface, it must have a tight

58
00:03:51,900 --> 00:03:52,290
property.

59
00:03:52,290 --> 00:04:00,660
That is exactly the string, Zorch roupas batteries error and it must have a payload that is a string.

60
00:04:01,980 --> 00:04:07,680
So we now have three different interfaces, one that exactly describes the three kinds of actions that

61
00:04:07,680 --> 00:04:10,950
we expect to eventually process inside of our repositories reducer.

62
00:04:11,400 --> 00:04:14,760
So at this point, I'm not really clear necessarily where we're going with this.

63
00:04:15,060 --> 00:04:20,420
So let's take a quick pause and see why having these three different interfaces is really, really handy.

