Skip to content

Instantly share code, notes, and snippets.

@soker90
Created June 28, 2021 09:05
Show Gist options
  • Save soker90/2f3f86066076f95984733b9aaf85eba5 to your computer and use it in GitHub Desktop.
Save soker90/2f3f86066076f95984733b9aaf85eba5 to your computer and use it in GitHub Desktop.
functional conditional
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