Created
June 28, 2021 09:05
-
-
Save soker90/2f3f86066076f95984733b9aaf85eba5 to your computer and use it in GitHub Desktop.
functional conditional
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
export const matched = param => ({ | |
on: () => matched(param), | |
otherwise: () => param, | |
}); | |
export const matchRedirect = param => ({ | |
on: (pred, fn) => (pred(param) ? matched(fn(param)) : matchRedirect(param)), | |
otherwise: fn => fn(param), | |
}); | |
export const emailRedirect = () => { | |
if (has.destination) { | |
return matchRedirect(has.destination) | |
.on(param => param === 'webviewEndYear', () => resultParams('openbrowser?url=webviewEndYear')) | |
.otherwise(param => resultParams(param)); | |
} | |
return resultParams('dashboard'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment