-
Notifications
You must be signed in to change notification settings - Fork 0
/
actions.js
107 lines (84 loc) · 2.48 KB
/
actions.js
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
const actions = [
// signup
"SIGNUP_SET_EMAIL",
"SIGNUP_SET_NAME",
"SIGNUP_SET_PASSWORD",
"SIGNUP_STARTED",
"SIGNUP_FAILED",
"SIGNUP_SUCCEEDED",
// signin
"SIGNIN_SET_EMAIL",
"SIGNIN_SET_PASSWORD",
"SIGNIN_STARTED",
"SIGNIN_FAILED",
"SIGNIN_SUCCEEDED",
"SIGNOUT_SUCCEEDED",
"TOKEN_UPDATED",
"FETCH_CURRENT_USER_STARTED",
"FETCH_CURRENT_USER_FAILED",
"FETCH_CURRENT_USER_SUCCEEDED",
"HOME_UPDATE_CURRENT_TAB",
"HOME_FETCHING_FEEDS_STARTED",
"HOME_FETCHING_FEEDS_FAILED",
"HOME_FETCHING_FEEDS_SUCCEEDED",
"HOME_FETCHING_ARTICLES_STARTED",
"HOME_FETCHING_ARTICLES_FAILED",
"HOME_FETCHING_ARTICLES_SUCCEEDED",
"HOME_FETCHING_TAGS_STARTED",
"HOME_FETCHING_TAGS_FAILED",
"HOME_FETCHING_TAGS_SUCCEEDED",
"HOME_UPDATE_FAVORITE_COUNT",
"HOME_UPDATE_PAGINATION_PAGE",
"EDITOR_POST_ARTICLE_STARTED",
"EDITOR_POST_ARTICLE_FAILED",
"EDITOR_POST_ARTICLE_SUCCEEDED",
"EDITOR_FETCH_ARTICLE_STARTED",
"EDITOR_FETCH_ARTICLE_FAILED",
"EDITOR_FETCH_ARTICLE_SUCCEEDED",
"EDITOR_UPDATE_TITLE",
"EDITOR_UPDATE_DESC",
"EDITOR_UPDATE_BODY",
"EDITOR_UPDATE_TAGS",
"FETCH_ARTICLE_STARTED",
"FETCH_ARTICLE_FAILED",
"FETCH_ARTICLE_SUCCEEDED",
"FETCH_COMMENTS_STARTED",
"FETCH_COMMENTS_FAILED",
"FETCH_COMMENTS_SUCCEEDED",
"FOLLOW_USER_STARTED",
"FOLLOW_USER_FAILED",
"FOLLOW_USER_SUCCEEDED",
"FAVORITE_ARTICLE_STARTED",
"FAVORITE_ARTICLE_FAILED",
"FAVORITE_ARTICLE_SUCCEEDED",
"UPDATE_USER_COMMENT",
"POST_COMMENT_SUCCEEDED",
"POST_COMMENT_FAILED",
"DELETE_COMMENT_SUCCEEDED",
"SETTINGS_UPDATE_INFO",
"SETTINGS_UPDATE_AVATAR",
"SETTINGS_UPDATE_BIO",
"SETTINGS_UPDATE_USERNAME",
"SETTINGS_UPDATE_EMAIL",
"SETTINGS_UPDATE_PASSWORD",
"PROFILE_FETCH_ARTICLES_STARTED",
"PROFILE_FETCH_ARTICLES_FAILED",
"PROFILE_FETCH_ARTICLES_SUCCEEDED",
"PROFILE_FETCH_PROFILE_STARTED",
"PROFILE_FETCH_PROFILE_FAILED",
"PROFILE_FETCH_PROFILE_SUCCEEDED",
"PROFILE_UPDATE_SELECTED_TAB",
"PROFILE_UPDATE_FAVORITE_STATS",
"PROFILE_UPDATE_FOLLOWING_STATS",
"PROFILE_UPDATE_CURRENT_PAGE",
"PROFILE_PROFILE_CHANGED",
"ARTICLE_SLUG_CHANGED"
];
const actionsObj = actions.reduce((acc, current) => {
acc[current] = current;
return acc;
}, {});
const error = name => {
throw Error(`NO SUCH ACTION: ${name}`);
};
export default name => actionsObj[name] || error(name);