@byloth/core 2.0.0-rc.1 → 2.0.0-rc.2

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.
@@ -1,7 +1,7 @@
1
1
  import { TimeUnit } from "../../utils/date.js";
2
2
 
3
3
  import { FatalErrorException, RangeException, RuntimeException } from "../exceptions/index.js";
4
- import { DeferredPromise } from "../promises/index.js";
4
+ import { DeferredPromise, SmartPromise } from "../promises/index.js";
5
5
 
6
6
  import GameLoop from "../game-loop.js";
7
7
  import Publisher from "../publisher.js";
@@ -22,12 +22,10 @@ export default class Countdown extends GameLoop
22
22
  return this._duration - this.elapsedTime;
23
23
  }
24
24
 
25
- public constructor(duration: number, fpsIfNotBrowser = TimeUnit.Second)
25
+ public constructor(duration: number, fpsIfNotBrowser: number = TimeUnit.Second)
26
26
  {
27
- const callback = (elapsedTime: number) =>
27
+ const callback = () =>
28
28
  {
29
- this._duration -= elapsedTime;
30
-
31
29
  const remainingTime = this.remainingTime;
32
30
  this._publisher.publish(remainingTime);
33
31
 
@@ -40,12 +38,12 @@ export default class Countdown extends GameLoop
40
38
  this._duration = duration;
41
39
  }
42
40
 
43
- public start(remainingTime: number = this.duration): DeferredPromise<void>
41
+ public start(remainingTime: number = this.duration): SmartPromise<void>
44
42
  {
45
43
  if (this._isRunning) { throw new RuntimeException("The countdown has already been started."); }
46
44
  if (this._deferrer) { throw new FatalErrorException(); }
47
45
 
48
- this._deferrer = new DeferredPromise(() => this.stop());
46
+ this._deferrer = new DeferredPromise();
49
47
  super.start(this.duration - remainingTime);
50
48
 
51
49
  return this._deferrer;