task.defer
Runs fn as soon as the current thread yields.
Syntax
task.defer(fn: function) -> nil
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | function | The function or callback to use. |
Returns
| Type | Description |
|---|---|
nil | This function does not return a value. |
Description
task.defer is part of the task library library. The task library runs on the VM's own scheduler; waits and delayed callbacks resume when the VM next ticks.
The operation is performed immediately using the arguments supplied at the call site.
Example
task.defer(function()
print("deferred")
end)
Notes
- Waits and delayed callbacks resume on the VM's scheduler.