README
js-dispatch
javascript dispatch task,like debounce and throttle,To see more details
Install
npm install js-dispatch --save
Options
const options = { ... };
new JSDispatch(options);
Field | Desc |
---|---|
timer | default:-1 |
step |
default:250 |
flag | default:false |
Useage
Browser
<script src="xxx/js-dispatch/dist/index.umd.js"></script>
var dispatch = new JSDispatch();
// some logic
function handleDebouceMove() {
dispatch.debounce(function () {
// TODO
})
}
// some logic
function handleThrottleMove() {
dispatch.throttle(function (done) {
// TODO
done()
})
}
ESModules
import JSDispatch from 'js-dispatch';
var dispatch = new JSDispatch();
// some logic
function handleDebouceMove() {
dispatch.debounce(function () {
// TODO
})
}
// some logic
function handleThrottleMove() {
dispatch.throttle(function (done) {
// TODO
done()
})
}
Node.js
const JSDispatch = require('js-dispatch');
var dispatch = new JSDispatch();
// some logic
function handleDebouceMove() {
dispatch.debounce(function () {
// TODO
})
}
// some logic
function handleThrottleMove() {
dispatch.throttle(function (done) {
// TODO
done()
})
}