diff --git a/README.md b/README.md index 052ebc8..4d8acc0 100644 --- a/README.md +++ b/README.md @@ -165,6 +165,8 @@ upcoming([option] [, cb]) => {Promise} ### Event types +#### Event: 'ready' - Emitted when the module is ready to process events. + #### Event: 'event' - Emitted when an event is received. The handler will be called with the following argument: diff --git a/lib/dtimer.js b/lib/dtimer.js index 4bd256a..c0a1c0e 100644 --- a/lib/dtimer.js +++ b/lib/dtimer.js @@ -81,6 +81,7 @@ function DTimer(id, pub, sub, option) { return; } debug(self._id+': lua loading successful'); + self.emit('ready'); }); this._maxEvents = this._option.maxEvents; diff --git a/test/ApiTests.js b/test/ApiTests.js index 04a54bb..43aa432 100644 --- a/test/ApiTests.js +++ b/test/ApiTests.js @@ -104,6 +104,14 @@ describe('ApiTests', function () { }); }); + it('emits ready after redis is setup successfully', function (done) { + var pub = redis.createClient(); + var dt = new DTimer('me', pub, null); + dt.on('ready', function () { + done(); + }); + }); + it('Detect malformed message on subscribe', function (done) { sandbox.stub(require('lured'), 'create', function () { return {