Skip to content

Commit

Permalink
Fix timer callback triggering after timer is cleared (elastic#865)
Browse files Browse the repository at this point in the history
* ensure that a timer has not already been cleared when calling the callback

* changelog
  • Loading branch information
chandlerprall committed May 24, 2018
1 parent 90d0904 commit 4cd0b09
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
**Bug fixes**

- `EuiButton`, `EuiButtonEmpty`, and `EuiButtonIcon` now look and behave disabled when `isDisabled={true}` ([#862](https://github.com/elastic/eui/pull/862))
- `EuiGlobalToastList` no longer triggers `Uncaught TypeError: _this.callback is not a function` ([#865](https://github.com/elastic/eui/pull/865))

## [`0.0.49`](https://github.com/elastic/eui/tree/v0.0.49)

Expand Down
5 changes: 4 additions & 1 deletion src/services/time/timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class Timer {

resume = () => {
this.id = setTimeout(this.finish, this.timeRemaining);
this.finishTime = Date.now() + this.timeRemaining;
this.timeRemaining = undefined;
};

Expand All @@ -26,7 +27,9 @@ export class Timer {
};

finish = () => {
this.callback();
if (this.callback) {
this.callback();
}
this.clear();
};
}

0 comments on commit 4cd0b09

Please sign in to comment.