Skip to content

Instantly share code, notes, and snippets.

@pragmaticlogic
Last active August 29, 2015 14:21
Show Gist options
  • Select an option

  • Save pragmaticlogic/242856713670109561fe to your computer and use it in GitHub Desktop.

Select an option

Save pragmaticlogic/242856713670109561fe to your computer and use it in GitHub Desktop.
onSearchClick
var onSearchClick = ((event) => {
//Impure
var element = this.refs.searchText.getDOMNode()
var focusElement = element => { element.value = ''; element.focus() }
var showResult = element => { Navigate(`/dashboard/${element.value}`) }
//Pure
var getInput = element => element.value
var isInputEmpty = R.eq('')
var checkInput = R.compose(isInputEmpty, R.trim, getInput)
var handleClick = R.ifElse(checkInput, focusElement, showResult)
//Kick things off
handleClick(element)
}).bind(context)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment