vdom-event-listener
v0.0.3
Published
a virtual-dom hook that adds eventListeners on dom nodes
Downloads
5
Maintainers
Readme
vdom-event-listener
A virtual-dom hook that adds eventListeners on dom nodes
Example
const h = require('virtual-dom/h')
const EventListener = require('vdom-event-listener')
function update (event) {
console.log('... received event', event, event.target.value)
}
function render () {
return h('input', {
className: 'i-has-class',
type: 'text',
value: 'initial value',
listeningHook: new EventListener(update)
})
}
render()
Usage
new EventListener(function handler (event), [eventType])
handler
is a function that takes the event that will be fired off as its only argument.
eventType
defaults to 'keydown'
, but for input types like 'checkbox'
it is better to use 'change'
.