2024-03-31 16:15:44 +11:00
|
|
|
---@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
|
2024-04-02 17:02:46 +11:00
|
|
|
end, ("failed to load %s '%s'"):format(assetType, asset), timeout)
|
2024-03-31 16:15:44 +11:00
|
|
|
end
|
2024-04-03 14:26:25 +11:00
|
|
|
|
|
|
|
|
return lib.streamingRequest
|