mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-16 22:46: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 an animation clipset. When called from a thread, it will yield until it has loaded.
|
||||
---@param animSet string
|
||||
---@param timeout number? Approximate milliseconds to wait for the clipset to load. Default is 1000.
|
||||
---@return string? animSet
|
||||
---@return string animSet
|
||||
function lib.requestAnimSet(animSet, timeout)
|
||||
if HasAnimSetLoaded(animSet) then return animSet end
|
||||
|
||||
@@ -9,13 +9,7 @@ function lib.requestAnimSet(animSet, timeout)
|
||||
error(("expected animSet to have type 'string' (received %s)"):format(type(animSet)))
|
||||
end
|
||||
|
||||
RequestAnimSet(animSet)
|
||||
|
||||
if not coroutine.isyieldable() then return animSet end
|
||||
|
||||
return lib.waitFor(function()
|
||||
if HasAnimSetLoaded(animSet) then return animSet end
|
||||
end, ("failed to load animSet '%s'"):format(animSet), timeout)
|
||||
return lib.streamingRequest(RequestAnimSet, HasAnimSetLoaded, 'animSet', animSet, timeout)
|
||||
end
|
||||
|
||||
return lib.requestAnimSet
|
||||
|
||||
Reference in New Issue
Block a user