Just answered my own question: AKA - YES!
So I just conducted a test here and here are my findings:
(Based HEAAAVILY off of your example)
function fadetest()
frst_promise = promise.new()
fadestatus = frst_promise
frst_promise:next(function(string)
print("Promise has been resolved! Fade that damned screen in!")
print(string)
DoScreenFadeIn(1000)
end, function(string)
print("Dad's still out with the milk - Promise Failed, STILL let's fade the screen in!")
print(string .. " of failure")
DoScreenFadeIn(1000)
end)
end
-- Gonna Call this the "Promise-Starter"
fadetest()
--[[ Gonna Call this one the "Promise-Tester"]]
CreateThread(function()
fadestatus:resolve("balls")
end)
--And this one is the "Promise-Awaiter"
CreateThread(function()
local faderesults = Citizen.Await(fadestatus)
print("promise is resolved - go live your life!")
print(faderesults)
--DoScreenFadedIn(1000)
Wait(0)
end)
So when I ran this WITHOUT the “promise starter” and just made a direct call to
fadestatus:resolve("balls")
I got an unrecognized global variable-related error. This is because while we created the function, the promise itself has yet to exist. It has yet to be initialized. This is why it’s important to have your “Promise-Starter” (where you call the enclosing function containing the promise).
Once that was called, I could make an attempt to resolve the promise using the “Promise-Tester”
And as a result, the string “balls” gets passed into the argument “string” and gets used there AND as a return from the variable ‘faderesults’
As a final example, in the behavior testing, in the “Promise-Awaiter” thread, if that’s on a while-true-do loop, what happens is as follows:
- While promise is unresolved, Nothing
- When promise gets resolved, it runs the code underneath in an infinite loop
- When the promise gets rejected, the variable “FadeResults” gets thrown as an error