swift-async-algorithms
swift-async-algorithms copied to clipboard
for await-latest ?
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