Skip to content

Instantly share code, notes, and snippets.

@rayrayzayzay
Created July 18, 2022 23:16
Show Gist options
  • Save rayrayzayzay/23874bfb9a5465249f77f34dfd88eafa to your computer and use it in GitHub Desktop.
Save rayrayzayzay/23874bfb9a5465249f77f34dfd88eafa to your computer and use it in GitHub Desktop.
✅ Explicit modeling of distinct states
type UserProfileFetching = {
status: "fetching"
}
type UserProfileSuccess = {
status: "success"
data: UserProfileData
statusCode: number
}
type UserProfileError = {
status: "error"
errorMessage: string
statusCode: number
}
type UserProfileRequest = UserProfileFetching |
UserProfileSuccess | UserProfileError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment