Last active
September 4, 2019 12:22
-
-
Save jrsinclair/ea5ee31deb2318d41b53607a3bda8e32 to your computer and use it in GitHub Desktop.
Fun with binding event handlers
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
const setAttr = _.curry((attrName, el, val) => { el.setAttribute(val)); return el; }); | |
const listen = _.curry((evtName, el, f) => { el.addEventListener(evtName, f); return el; }) | |
const bindCreateResultButton = (createResultButton, postTextarea, getPostData, preTextarea) => | |
_.compose( | |
listen('click', createResultButton), | |
_.compose(x => () => setAttr('value', postTextArea, x), getPostData), | |
)(preTextArea); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For posterity, here's a link to the pen: https://codepen.io/rosefalk/pen/QWLpZEY?editors=0011