apple / apple/swift-async-algorithms
for await-latest ?
- Dominant language
- Swift
- Stars
- 3.7k
- Forks
- 226
- Avg merge
- 10d 3h
- Merged PRs (30d)
- 1
Description
Hi, we need to be able to iterate over async sequence such that if the iteration does some async stuff & upstream happens to emit in the middle of it, the current iteration is cancelled & next one is subscribed (i.e. it doesn't wait)
```
for item in items.latest {
try await sleep(long time)
}
```
this would mirror kotlin's `collectLatest (also there's flatMapLatest, transformLatest` which are very powerful & necessary
Contributor guide
Research direction
Start by reviewing the repository's existing AsyncSequence APIs and the issue's Kotlin collectLatest comparison; no implementation files or tests are named. Define the cancellation and resubscription behavior for items.latest, then add coverage showing that an in-progress iteration is cancelled when a newer upstream item arrives.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100