Comments (3)
@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.
from swift-async-algorithms.
Hi
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.
from swift-async-algorithms.
Thanks to you both - that guidance and info is much appreciated.
I'll see if I can work out how to extend the existing code to support different arities in my local project.
I'll also go read up on the parameter packs pitch by Holly and Slava - I'm really excited by this bit of work!
from swift-async-algorithms.
Related Issues (20)
- Tests fail with the iOS simulator HOT 1
- Removed `Task.select(_:)` method is still called. HOT 3
- `Sequence`-based implementation of combining algorithms in addition to variadic ones HOT 1
- Provide an option for chunking based on a signal to include empty chunks
- A throttled `AsyncSequence` doesn't yield its parent sequence's final value HOT 24
- Iterating `combineLatest`, `merge`, `zip` and `debounce` when Task is already cancelled HOT 1
- Several tests fail or hang on linux with the official trunk snapshot toolchains HOT 5
- Debounce does not yield values if rate is higher than the pace of the stream HOT 2
- Compiler crash in AsyncChannel HOT 1
- For `Void` element AsyncSequence types it might be nice to have a `waitForAll() async rethrows` similar to TaskGroup HOT 1
- `throttle` does not emit the latest element at interval occurrence when latest is `true` HOT 24
- `AsyncChunksOfCountSequence` does not create chunks of 1 element each. HOT 1
- Debounce silently swallows thrown errors and stalls iteration HOT 7
- Type erasure of AsyncSequences HOT 6
- Build warnings on Xcode 15/Swift 5.9 in AsyncBufferSequence.swift HOT 1
- How do I cancel async task when using AsyncChannel HOT 1
- Documentation for interspersed(with:) contains a bad link
- Debounce behaving weirdly in proposed unit test
- README and Guides are missing docs for `buffer(policy:)`
- No way to cancel `AsyncChannel` producer task when consumer task finishes early HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swift-async-algorithms.