Last active
May 16, 2019 10:34
-
-
Save klemola/83840cfa571f89d87430ddb78e4245af to your computer and use it in GitHub Desktop.
This file contains 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
function render( | |
userRequest: RemoteData<User, Error>, | |
translationsRequest: RemoteData<Translations, Error> | |
) { | |
if (isLoading(userRequest) || isLoading(translationsRequest)) { | |
return "Loading..."; | |
} else if (isSuccess(userRequest) && isSuccess(translationsRequest)) { | |
const { username } = userRequest.data; | |
const { greeting } = translationsRequest.data; | |
return `${greeting}, ${username}`; | |
} else if (isFailure(userRequest) || isFailure(translationsRequest)) { | |
return "Could not initialize the application!"; | |
} else { | |
return null; | |
} | |
} | |
/* ...simulated fetch functions */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment