Yuari
Documentation
Docs/task library/task.defer

task.defer

Runs fn as soon as the current thread yields.

Syntax

task.defer(fn: function) -> nil

Parameters

ParameterTypeDescription
fnfunctionThe function or callback to use.

Returns

TypeDescription
nilThis 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.