natiny.resource.load_async
natiny.resource.load_async(path, callback)
Asynchronously loads a resource. The callback fires when the resource is ready.
Parameters
| Name | Type | Description |
|---|---|---|
path |
string |
Path to the resource file |
callback |
function |
function(resource) called on completion |
Callback
The callback receives one argument:
- resource - loaded resource handle, or nil on failure.
Example
natiny.resource.load_async("data/textures/texture.png", function(resource)
if resource then
tex = natiny.texture.create(resource)
else
print("Failed to load texture!")
end
end)
Notes
- Completed callbacks are dispatched automatically by
natiny.backend.loopbefore the frame callback runs. - Ideal for large assets that should not block the main thread.