ludobits
ludobits copied to clipboard
Flow API suggestion
"Fork-join" model fits pretty well for several async animations (you can spawn a lot of flow in parallel), but there is no "wait for flow" api in module. I came up with code like this, but there is probably better way to implement such functionality.
local function flow_wait_others(flows)
assert(flows)
-- single coroutine
if flow.co then
flow.until_true(function(args)
return coroutine.status(flow.co) == "dead"
end)
return
end
-- several coroutines
for k, v in pairs(flows) do
flow.until_true(function(args)
return coroutine.status(v.co) == "dead"
end)
end
end
I haven't paid much attention to the flow module lately. I think it takes on too many responsibilities and if I were to redo it I'd probably focus on forking and joining and leaving the different functions for waiting for http requests, animations and more out of the flow module.
BUT your suggestion to add a function to wait for one or more other flows makes sense. Please submit a PR with your change and I'll happily merge it!
I think you could close this issue.