@eryx/task Module

JSON

Roblox-compatible task scheduling library backed by libuv timers.

Example:

local task = require("@eryx/task")

task.spawn(function()
	print("tick 1")
	local dt = task.wait(1)
	print("tick 2 after", dt, "s")
end)

When the top-level script yields, the libuv event loop drives timer callbacks that resume coroutines automatically - no manual task.step() call is required (though it is still available for backward compatibility).

Summary

Functions

task.spawn<A..., R...>(functionOrThread: (((A...) → R...)) | thread, ...)thread
task.defer<A..., R...>(functionOrThread: (((A...) → R...)) | thread, ...)thread
task.delay<A..., R...>(duration: number?, functionOrThread: (((A...) → R...)) | thread, ...)thread
task.wait(duration: number?)number
task.cancel(t: thread)()

API Reference

Functions

task.spawn

task.spawn<A..., R...>(functionOrThread: (((A...) → R...)) | thread, ...)thread

task.defer

task.defer<A..., R...>(functionOrThread: (((A...) → R...)) | thread, ...)thread

task.delay

task.delay<A..., R...>(duration: number?, functionOrThread: (((A...) → R...)) | thread, ...)thread

task.wait

task.wait(duration: number?)number

task.cancel

task.cancel(t: thread)()