kentcdodds / es6-todomvc

The vanillajs example converted to es6
https://kcd.im/webpack-workshop-repo
MIT License
351 stars 358 forks source link

$on() Does not allow options param #26

Closed Tahseenm closed 7 years ago

Tahseenm commented 7 years ago

Hi Kent, Thanks for the awesome course! Helped me a lot moving from Gulp. Just noticed $on(elem, type, cb, { once: true }) would not work as expected.

Future proof version :+1:

/**
 * Wrapper for `addEventListener`
 *
 * @param {HTMLElement} target
 * @param {string} eventType
 * @param {function} eventHandler
 * @param {boolean|Object.<boolean>} options - useCapture OR
 * {capture, once, passive}
 */
function $on(target, eventType, eventHandler, opt = false) {
  target.addEventListener(eventType, eventHandler, opt);
}
kentcdodds commented 7 years ago

Thanks for the feedback! Normally I'd invite you to contribute by making a PR, but due to the unique nature of this project and all the lesson/step branches, it's pretty difficult to make changes. Thanks though!