You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from what I know this is something that should arrive when generic variadics are available so we are not constrained to merging the same types of AsyncSequence.
Perhaps there are workarounds in your case. One that comes to my mind is (perhaps not the most efficient though):
Having a task group where you iterate over every channel you have (a task per channel) and send the elements to a single Channel. This “output” channel will act as a merging bus. You can then iterate over this single channel in another task.
@twittemb Is right here that this is something we ought to be able to do one variadic generics land. My position right now is to avoid adding sequence based APIs since they have a few downsides such as introducing an array allocation which could be avoided.
What I can recommend you for the time being is either of these two:
If merge is last transformation applied to your sequence chain then you can as @twittemb pointed out maybe use a task group and merge from there by just creating a child task for each upstream and calling next on the group repeatedly.
You could copy the code that is used for the implementation of merge and just extend it to whatever arity you need. This involves very minor changes and a bit of code duplication.
I've got a use case where I have an unknown number of
AsyncChannel
s that I want to merge into a single stream of events.It'd be wonderful if
merge(…)
and friends supported more than an arity of 3 - ideally accepting a sequence?Thanks!
The text was updated successfully, but these errors were encountered: