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
  • Loading branch information
ycombinator authored Jun 20, 2016
2 parents e30b7b6 + 706b4d9 commit 5b0a0d2
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 5b0a0d2

Please sign in to comment.