gitcoinco/code_fund_ads

View on GitHub
app/javascript/events/value_committed_event.js

Summary

Maintainability
A
0 mins
Test Coverage
import { debounce } from 'lodash'

function newValueCommittedEvent () {
  return new CustomEvent('cf:value-committed', {
    bubbles: true
  })
}

const wait = 750 // milliseconds

const dispatch = debounce(element => {
  element.dispatchEvent(newValueCommittedEvent())
}, wait)

document.addEventListener('input', event => dispatch(event.target), true)

export default newValueCommittedEvent