Skip to content

Instantly share code, notes, and snippets.

@anthony2025
Created June 5, 2018 17:35
Show Gist options
  • Save anthony2025/dd964c1e535c746cdb09cae4197d5e32 to your computer and use it in GitHub Desktop.
Save anthony2025/dd964c1e535c746cdb09cae4197d5e32 to your computer and use it in GitHub Desktop.
for use inside compose/flow statements, branches based on a 'predicate' (more precisely just a boolean value)
export const conditional = <T>(predicate: boolean, ifTrue: T => *, ifFalse: T => *) =>
(value: T) => predicate ? ifTrue(value) : ifFalse(value);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment