Skip to content

Commit

Permalink
fix(events): resolve async events without any listener
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtajina committed Dec 23, 2013
1 parent 0586a4e commit 4e4bba8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ var EventEmitter = function() {

this.emit(name, done);

if (!pending) {
deferred.resolve();
}

return deferred.promise;
};
};
Expand Down
6 changes: 6 additions & 0 deletions test/unit/events.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ describe 'events', ->
done()


it 'should resolve asynchronously when no listener', (done) ->
spyDone = sinon.spy done
emitter.emitAsync('whatever').then spyDone
expect(spyDone).to.not.have.been.called


#============================================================================
# events.bindAll
#============================================================================
Expand Down

0 comments on commit 4e4bba8

Please sign in to comment.