mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
refactor(streamingRequest): internal method for request functions
- TS package type inference for request functions. - Type fix for Lua's waitFor callback. - Lua request functions cannot return nil.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
---Load a texture dictionary. When called from a thread, it will yield until it has loaded.
|
||||
---@param textureDict string
|
||||
---@param timeout number? Approximate milliseconds to wait for the dictionary to load. Default is 1000.
|
||||
---@return string? textureDict
|
||||
---@return string textureDict
|
||||
function lib.requestStreamedTextureDict(textureDict, timeout)
|
||||
if HasStreamedTextureDictLoaded(textureDict) then return textureDict end
|
||||
|
||||
@@ -9,13 +9,7 @@ function lib.requestStreamedTextureDict(textureDict, timeout)
|
||||
error(("expected textureDict to have type 'string' (received %s)"):format(type(textureDict)))
|
||||
end
|
||||
|
||||
RequestStreamedTextureDict(textureDict, false)
|
||||
|
||||
if not coroutine.isyieldable() then return textureDict end
|
||||
|
||||
return lib.waitFor(function()
|
||||
if HasStreamedTextureDictLoaded(textureDict) then return textureDict end
|
||||
end, ("failed to load textureDict '%s'"):format(textureDict), timeout)
|
||||
return lib.streamingRequest(RequestStreamedTextureDict, HasStreamedTextureDictLoaded, 'textureDict', textureDict, timeout)
|
||||
end
|
||||
|
||||
return lib.requestStreamedTextureDict
|
||||
|
||||
Reference in New Issue
Block a user