mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-11-28 05:14:44 +00: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 parent
e3ece4f337
commit
0f0c7a6591
10 files changed
+50
-74
No files matched your search
@@ -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