Last active
August 29, 2015 14:21
-
-
Save pragmaticlogic/242856713670109561fe to your computer and use it in GitHub Desktop.
onSearchClick
This file contains hidden or 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
| 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