Skip to content

Instantly share code, notes, and snippets.

@Maxim-Filimonov
Last active August 29, 2015 14:27
Show Gist options
  • Save Maxim-Filimonov/1fa3e78f0172dbe7fc6f to your computer and use it in GitHub Desktop.
Save Maxim-Filimonov/1fa3e78f0172dbe7fc6f to your computer and use it in GitHub Desktop.
Magic of Ramda maybes
createLogo() {
R.compose(R.map(function (v) {
return <img src={v}/>
}), R.pluck('logo'), RF.Maybe);
},
defaultLogo() {
return undefined;
},
render() {
if (!this.data.loading) {
return (
<div className="ui container">
<header style={this.style.header} className="ui centered grid">
{this.createLogo(this.data.event).getOrElse(this.defaultLogo())}
</header>
{this.renderContent()}
</div>
)
@Svetixbot
Copy link

Anyway, you need:
Compose(createDomForImg, Maybe(this.data.event).getOrElse(this.default))

@Maxim-Filimonov
Copy link
Author

That is called point free programMing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment