Skip to content

Commit

Permalink
Merge pull request elastic#7513 from ycombinator/emit-new-status-on-c…
Browse files Browse the repository at this point in the history
…hange

Emit new state + message as well, on status change

Former-commit-id: 5b0a0d2
  • Loading branch information
ycombinator authored Jun 20, 2016
2 parents 8041ead + c8bf8b0 commit 2e549fd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions src/server/status/__tests__/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ describe('Status class', function () {
it('emits change when the status is set', function (done) {
let status = serverStatus.createForPlugin(plugin);

status.once('change', function (prev, prevMsg) {
expect(status.state).to.be('green');
expect(status.message).to.be('GREEN');
expect(prev).to.be('uninitialized');

status.once('change', function (prev, prevMsg) {
expect(status.state).to.be('red');
expect(status.message).to.be('RED');
expect(prev).to.be('green');
status.once('change', function (prevState, prevMsg, newState, newMsg) {
expect(newState).to.be('green');
expect(newMsg).to.be('GREEN');
expect(prevState).to.be('uninitialized');

status.once('change', function (prevState, prevMsg, newState, newMsg) {
expect(newState).to.be('red');
expect(newMsg).to.be('RED');
expect(prevState).to.be('green');
expect(prevMsg).to.be('GREEN');

done();
Expand Down
4 changes: 2 additions & 2 deletions src/server/status/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ states.all.forEach(function (state) {
return;
}

this.emit(state.id, previous, previousMsg);
this.emit('change', previous, previousMsg);
this.emit(state.id, previous, previousMsg, this.state, this.message);
this.emit('change', previous, previousMsg, this.state, this.message);
};
});

Expand Down

0 comments on commit 2e549fd

Please sign in to comment.