debounce-events
v0.0.2
Published
Global events debounce using redis
Downloads
2
Readme
debounce-events
Global events debounce using redis
Installation
$ npm install --save debounce-events
Usage
Example 1:
var Channel = require('debounce-events');
var ch = new Channel(function update() {
// do something...
});
ch.emit('update');
ch.emit('update');
ch.emit('update');
ch.emit('update'); // only update once
Example 2:
var Redis = require('ioredis');
var Channel = require('debounce-events');
var ch = new Channel(function update() {
// do something
}, {
wait: 50,
adapter: Channel.ADAPTER_REDIS,
redisClient: new Redis()
});
ch.emit('update1'); // emit update1
ch.emit('update1'); // same event will only emit once
ch.emit('update2'); // emit other event: update2
License
MIT © Gaara