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,19 +1,13 @@
|
||||
---Load a scaleform movie. When called from a thread, it will yield until it has loaded.
|
||||
---@param scaleformName string
|
||||
---@param timeout number? Approximate milliseconds to wait for the scaleform movie to load. Default is 1000.
|
||||
---@return number? scaleform
|
||||
---@return number scaleform
|
||||
function lib.requestScaleformMovie(scaleformName, timeout)
|
||||
if type(scaleformName) ~= 'string' then
|
||||
error(("expected scaleformName to have type 'string' (received %s)"):format(type(scaleformName)))
|
||||
end
|
||||
|
||||
local scaleform = RequestScaleformMovie(scaleformName)
|
||||
|
||||
if not coroutine.isyieldable() then return scaleform end
|
||||
|
||||
return lib.waitFor(function()
|
||||
if HasScaleformMovieLoaded(scaleform) then return scaleform end
|
||||
end, ("failed to load scaleform '%s'"):format(scaleform), timeout)
|
||||
return lib.streamingRequest(RequestScaleformMovie, HasScaleformMovieLoaded, 'scaleformMovie', scaleformName, timeout)
|
||||
end
|
||||
|
||||
return lib.requestScaleformMovie
|
||||
|
||||
Reference in New Issue
Block a user