mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 15:36:02 +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 an animation dictionary. When called from a thread, it will yield until it has loaded.
|
||||
---@param animDict string
|
||||
---@param timeout number? Approximate milliseconds to wait for the dictionary to load. Default is 1000.
|
||||
---@return string? animDict
|
||||
---@return string animDict
|
||||
function lib.requestAnimDict(animDict, timeout)
|
||||
if HasAnimDictLoaded(animDict) then return animDict end
|
||||
|
||||
@@ -10,16 +10,10 @@ function lib.requestAnimDict(animDict, timeout)
|
||||
end
|
||||
|
||||
if not DoesAnimDictExist(animDict) then
|
||||
return error(("attempted to load invalid animDict '%s'"):format(animDict))
|
||||
error(("attempted to load invalid animDict '%s'"):format(animDict))
|
||||
end
|
||||
|
||||
RequestAnimDict(animDict)
|
||||
|
||||
if not coroutine.isyieldable() then return animDict end
|
||||
|
||||
return lib.waitFor(function()
|
||||
if HasAnimDictLoaded(animDict) then return animDict end
|
||||
end, ("failed to load animDict '%s'"):format(animDict), timeout)
|
||||
return lib.streamingRequest(RequestAnimDict, HasAnimDictLoaded, 'animDict', animDict, timeout)
|
||||
end
|
||||
|
||||
return lib.requestAnimDict
|
||||
|
||||
Reference in New Issue
Block a user