From 9d6e8a366b6bc87a6246bf8b72d461497d28e160 Mon Sep 17 00:00:00 2001 From: Niklas Kapelle Date: Fri, 18 Oct 2024 16:37:46 +0200 Subject: [PATCH] fixed SinglePromise reset order --- src/lib/SinglePromise.hx | 11 +++++++++-- src/lib/SingleTimeoutPromise.hx | 8 ++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/lib/SinglePromise.hx b/src/lib/SinglePromise.hx index 9b92a32..d7c2d99 100644 --- a/src/lib/SinglePromise.hx +++ b/src/lib/SinglePromise.hx @@ -1,5 +1,7 @@ package lib; +import kernel.EndOfLoop; + using tink.CoreApi; class SinglePromise { @@ -15,6 +17,7 @@ class SinglePromise { public function request():Promise { if (this.inProgress) { + trace("Is progress"); return this.interalPromise; } @@ -32,17 +35,21 @@ class SinglePromise { return this.interalPromise; } + public function isRunning():Bool { + return this.inProgress; + } + public function resolve(val:T) { if (this.inProgress) { - this.interalResolve(val); this.inProgress = false; + this.interalResolve(val); } } public function reject(err:Error) { if (this.inProgress) { - this.interalReject(err); this.inProgress = false; + this.interalReject(err); } } } diff --git a/src/lib/SingleTimeoutPromise.hx b/src/lib/SingleTimeoutPromise.hx index d7c4442..cb1d95f 100644 --- a/src/lib/SingleTimeoutPromise.hx +++ b/src/lib/SingleTimeoutPromise.hx @@ -42,19 +42,23 @@ class SingleTimeoutPromise { return this.interalPromise; } + public function isRunning():Bool { + return this.inProgress; + } + public function resolve(val:T) { if (this.inProgress) { - this.interalResolve(val); this.inProgress = false; this.timer.cancle(); + this.interalResolve(val); } } public function reject(err:Error) { if (this.inProgress) { - this.interalReject(err); this.inProgress = false; this.timer.cancle(); + this.interalReject(err); } } }