vue-plugin: block event when callback is pedding!
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
src
test
types
.babelrc
.gitignore
.travis.yml
karma.conf.js
package.json
readme.md

readme.md

Build Status npm

vue-event-debounce

Support TypeScript!

Block event when callback is pedding! autoresolve Promise/generator.

blog: http://quanweili.com/2017/10/27/introduce-vue-event-debounce.html

Install

npm install vue-event-debounce --save

Usag

...
import VED from 'vue-event-debounce'

Vue.use(VED, { events: ['click'] })
...

and then, in component we can using a bounce event for click!

<template>
  <button v-click="myclick">click me</button>
</template>


<script>
export default {
  ...
  methods: {
    myclick (e) {
      // this is may be a ajax request, or just simple function
      return new Promise(function (resolve) {
        setTimeout(resolve.bind(this, 0), 3000)
      })
    }
  }
  ...
}
</script>

Options

  • events: array , directive name and event name.

Vue.use(VED, { events: ['click', 'keydown', 'keyup']})

will be bind directive v-click v-keydown v-keyup to Vue.