@dra2020/baseclient 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -994,9 +994,17 @@ class FsmSleep extends Fsm {
994
994
  this.delay = delay;
995
995
  }
996
996
  tick() {
997
- if (this.ready && this.state === exports.FSM_STARTING) {
997
+ // This allows canceling by simply setting state to done
998
+ if (this.done && this.timeoutHandle !== undefined) {
999
+ clearTimeout(this.timeoutHandle);
1000
+ delete this.timeoutHandle;
1001
+ }
1002
+ else if (this.ready && this.state === exports.FSM_STARTING) {
998
1003
  this.setState(exports.FSM_PENDING);
999
- setTimeout(() => { this.setState(exports.FSM_DONE); }, this.delay);
1004
+ this.timeoutHandle = setTimeout(() => {
1005
+ delete this.timeoutHandle;
1006
+ this.setState(exports.FSM_DONE);
1007
+ }, this.delay);
1000
1008
  }
1001
1009
  }
1002
1010
  }