fixed SinglePromise reset order
This commit is contained in:
parent
5167533c6d
commit
9d6e8a366b
@ -1,5 +1,7 @@
|
|||||||
package lib;
|
package lib;
|
||||||
|
|
||||||
|
import kernel.EndOfLoop;
|
||||||
|
|
||||||
using tink.CoreApi;
|
using tink.CoreApi;
|
||||||
|
|
||||||
class SinglePromise<T> {
|
class SinglePromise<T> {
|
||||||
@ -15,6 +17,7 @@ class SinglePromise<T> {
|
|||||||
|
|
||||||
public function request():Promise<T> {
|
public function request():Promise<T> {
|
||||||
if (this.inProgress) {
|
if (this.inProgress) {
|
||||||
|
trace("Is progress");
|
||||||
return this.interalPromise;
|
return this.interalPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,17 +35,21 @@ class SinglePromise<T> {
|
|||||||
return this.interalPromise;
|
return this.interalPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isRunning():Bool {
|
||||||
|
return this.inProgress;
|
||||||
|
}
|
||||||
|
|
||||||
public function resolve(val:T) {
|
public function resolve(val:T) {
|
||||||
if (this.inProgress) {
|
if (this.inProgress) {
|
||||||
this.interalResolve(val);
|
|
||||||
this.inProgress = false;
|
this.inProgress = false;
|
||||||
|
this.interalResolve(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reject(err:Error) {
|
public function reject(err:Error) {
|
||||||
if (this.inProgress) {
|
if (this.inProgress) {
|
||||||
this.interalReject(err);
|
|
||||||
this.inProgress = false;
|
this.inProgress = false;
|
||||||
|
this.interalReject(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,19 +42,23 @@ class SingleTimeoutPromise<T> {
|
|||||||
return this.interalPromise;
|
return this.interalPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isRunning():Bool {
|
||||||
|
return this.inProgress;
|
||||||
|
}
|
||||||
|
|
||||||
public function resolve(val:T) {
|
public function resolve(val:T) {
|
||||||
if (this.inProgress) {
|
if (this.inProgress) {
|
||||||
this.interalResolve(val);
|
|
||||||
this.inProgress = false;
|
this.inProgress = false;
|
||||||
this.timer.cancle();
|
this.timer.cancle();
|
||||||
|
this.interalResolve(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reject(err:Error) {
|
public function reject(err:Error) {
|
||||||
if (this.inProgress) {
|
if (this.inProgress) {
|
||||||
this.interalReject(err);
|
|
||||||
this.inProgress = false;
|
this.inProgress = false;
|
||||||
this.timer.cancle();
|
this.timer.cancle();
|
||||||
|
this.interalReject(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user