mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 15:06:02 +01:00
22 lines
561 B
Lua
22 lines
561 B
Lua
---@async
|
|
---@package
|
|
---@generic T : string | number
|
|
---@param request function
|
|
---@param hasLoaded function
|
|
---@param assetType string
|
|
---@param asset T
|
|
---@param timeout? number
|
|
---@param ... any
|
|
---Used internally.
|
|
function lib.streamingRequest(request, hasLoaded, assetType, asset, timeout, ...)
|
|
if hasLoaded(asset) then return asset end
|
|
|
|
request(asset, ...)
|
|
|
|
return lib.waitFor(function()
|
|
if hasLoaded(asset) then return asset end
|
|
end, ("failed to load %s '%s'"):format(assetType, asset), timeout)
|
|
end
|
|
|
|
return lib.streamingRequest
|