Last active
November 12, 2020 06:58
-
-
Save guillaumewuip/a06ae49f2b37ee1ba26caac01b761234 to your computer and use it in GitHub Desktop.
State and Store in frontend codebases - Redux example - actionCreators
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const fetchUsers = () => ({ | |
type: "FETCH_USERS" | |
}); | |
export const fetchUsersFailed = () => ({ | |
type: "FETCH_USERS_FAILED" | |
}); | |
export const fetchUsersSucceeded = (users) => ({ | |
type: "FETCH_USERS_SUCCEEDED", | |
payload: { | |
users | |
} | |
}); | |
export const createUser = (firstName, lastName, picture) => ({ | |
type: "CREATE_USER", | |
payload: { | |
id: Math.round(Math.random() * 1000000), | |
firstName, | |
lastName, | |
picture | |
} | |
}); | |
export const createUserFailed = () => ({ type: "CREATE_USER_FAILED" }); | |
export const createUserSucceeded = (payload) => ({ | |
type: "CREATE_USER_SUCCEEDED", | |
payload: { user: payload } | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment