Code: Select all
class test {
__Delete() => OutputDebug('del`n')
__New(fn) {
this.v := ''
this.r := ''
t := reject
resolve(val) {
if 0
val.then(resolve, reject) ; `this` is not captured, the destructor is called before the function is executed. In theory, this is a circular reference
; val.then(resolve, t) ; work
; val.then(reject) ; work
; val.then(resolve) ; work
this.v := val
}
reject(reason) {
this.r := reason
}
fn(resolve)
}
}
test(e => SetTimer(() => e(1), -500))
Sleep(600)