-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.ts
40 lines (32 loc) · 839 Bytes
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// User account at Hackernews.
export interface Author {
id: string;
karma: number;
created: number;
submitted: number[];
};
// Authors already loaded from API are stored in state.
export interface AuthorCache {
[authorId: string]: Author;
};
// News story from Hackernews.
export interface Story {
by: string;
id: number;
score: number;
time: number;
title: string;
url?: string;
};
// Stories already loaded from API are stored in state.
export interface StoryCache {
[storyId: number]: Story;
};
// Combination of subcaches. Also used as a state interface for _app
// since the context provider also conforms to this signature.
export interface Cache {
authorCache: AuthorCache;
storyCache: StoryCache;
updateAuthorCache: (author: Author) => void;
updateStoryCache: (stories: Story[]) => void;
}