-- Compiled with roblox-ts v3.0.0 local TS = _G[script] local useHookState = TS.import(script, script.Parent.Parent, "topo").useHookState local useChange = TS.import(script, script.Parent, "use-change").useChange local function useAsync(callback, dependencies, discriminator) local storage = useHookState(discriminator, function(state) local promise = state.promise promise:cancel() return false end) if useChange(dependencies, storage) then storage.promise:cancel() storage.promise = callback() storage.promise:andThen(function(value) storage.value = value end, function(err) storage.value = err end) storage.promise:finally(function() storage.status = storage.promise:getStatus() end) end return storage.status, storage.value end return { useAsync = useAsync, }