Skip to content

Instantly share code, notes, and snippets.

@choonkending
Last active June 6, 2017 23:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save choonkending/57a8ce44d4a317cf576d6eb76113feb6 to your computer and use it in GitHub Desktop.
Save choonkending/57a8ce44d4a317cf576d6eb76113feb6 to your computer and use it in GitHub Desktop.
const transformCage = () => { /* ... */ };
const handleError = e => "failed to parse Cage";
const handleSuccess = data => "Success";
const ifEmpty = () => "Cage does not exist!";
const doSomethingWithUserData = () =>
getUserFromLocalStorage('nickCage')
.fold(handleError,
data =>
data.map(transformCage)
.fold(
ifEmpty,
handleSuccess
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment