local h = Promise.new(function(resolve)
wait(3)
resolve()
end)
local andthen1 = h:andThen(function()
print("this should NOT print, but it does today")
end)
local andthen2 = h:andThen(function()
print("this should print")
end)
andthen1:cancel()
x = Promise.new(executor), with executor function executor,
and then chain onto it with andThen.
In effect, calling x:andThen(cb) is registering a callback (cb) to be run when x resolves. it returns a new promise, y, whose executor you do not control; it's controlled by the promise library, and it is what calls cb internally.
This is different, because the code inside cb is not related to promise y in the same way that the code in executor is related to promise x
I think this is confusing behavior, so we can just change it in a new version
x = Promise.new(executor)
, with executor functionexecutor
, and then chain onto it withandThen
.In effect, calling
x:andThen(cb)
is registering a callback (cb
) to be run whenx
resolves. it returns a new promise,y
, whose executor you do not control; it's controlled by the promise library, and it is what callscb
internally.This is different, because the code inside
cb
is not related to promisey
in the same way that the code inexecutor
is related to promisex
I think this is confusing behavior, so we can just change it in a new version