0.0.2 • Published 6 years ago

debounce-events v0.0.2

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

debounce-events NPM version Build Status

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