self:resolve
Shared
Resolves the promise with the given values, resuming any threads awaiting it
Syntax
local status = self:resolve(
...
)A promise can only be settled once. Calling self:resolve or self:reject on an already-settled promise has no effect and returns false.
- Pending — the promise is resolved and all awaiting threads are resumed with the provided values.
- Already settled — the call is ignored and
falseis returned.
Parameters
| Type | Name | Description |
|---|---|---|
any | ... | One or more values to resolve the promise with |
Returns
| Type | Name | Description |
|---|---|---|
bool | status | true if the promise was successfully resolved, false if it was already settled |
Examples
local entity = util.promise.create()
entity:resolve(true)local entity = util.promise.create()
entity:resolve("hello", "world")
util.thread.create(function(self)
local a, b = self:await(entity)
core.engine.print("info", a, b) -- 'hello' 'world'
end):resume()local entity = util.promise.create()
entity:resolve(true)
core.engine.print("info", entity:resolve(false)) -- false