ludobits icon indicating copy to clipboard operation
ludobits copied to clipboard

Flow API suggestion

Open Vbif opened this issue 4 years ago • 1 comments

"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

Vbif avatar Nov 10 '21 20:11 Vbif

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!

britzl avatar Nov 11 '21 15:11 britzl

I think you could close this issue.

mikhail-gudkov avatar Jan 22 '23 15:01 mikhail-gudkov