All files / src/containers/SingleSignOn Timer.js

100% Statements 6/6
100% Branches 2/2
100% Functions 3/3
100% Lines 6/6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18    3x       5x 5x       5x 2x 2x        
export default class GlobalTimer {
  constructor() {
    this._timerHandler = undefined;
  }
 
  invoke(callback, duration) {
    this.cancel();
    this._timerHandler = setTimeout(callback, duration);
  }
 
  cancel() {
    if (this._timerHandler) {
      clearTimeout(this._timerHandler);
      this._timerHandler = undefined;
    }
  }
}