1.0.0 • Published 6 years ago

deko-debounce v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

deko-debounce build status

debounce decorator for deko.

const deko = require('deko')
const debounce = require('deko-debounce')

class WorldClass {
  constructor() {
    deko(this)
  }

  static $$ontypedDebounced() {
     return [ debounce({ wait: 50 }) ]
  } ontypedDebounced(e) {
    // do stuff here
  }
}

const worldClass = new WorldClass()

for (var i = 0; i < 5; i++) {
  worldClass.ontypedDebounced()
}
// ontypedDebounced only executes one time after 50ms elapsed

Installation

npm install deko-debounce

API

debounce

Creates a debounce decorator to be used with deko

Parameters

  • $0 Object config
    • $0.wait Number number of milliseconds for which to postpone executions
    • $0.immediate Boolean if true causes debounce to trigger the function on the leading edge instead of the trailing edge of the wait interval

Returns Object debounceDecorator to be used with deko

License

MIT