-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction-creators.js
39 lines (32 loc) · 1.17 KB
/
action-creators.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
// ❗ You don't need to add extra action creators to achieve MVP
export function moveClockwise() { }
export function moveCounterClockwise() { }
export function selectAnswer() { }
export function setMessage() { }
export function setQuiz() { }
export function inputChange() { }
export function resetForm() { }
// ❗ Async action creators
export function fetchQuiz() {
return function (dispatch) {
// First, dispatch an action to reset the quiz state (so the "Loading next quiz..." message can display)
// On successful GET:
// - Dispatch an action to send the obtained quiz to its state
}
}
export function postAnswer() {
return function (dispatch) {
// On successful POST:
// - Dispatch an action to reset the selected answer state
// - Dispatch an action to set the server message to state
// - Dispatch the fetching of the next quiz
}
}
export function postQuiz() {
return function (dispatch) {
// On successful POST:
// - Dispatch the correct message to the the appropriate state
// - Dispatch the resetting of the form
}
}
// ❗ On promise rejections, use log statements or breakpoints, and put an appropriate error message in state