swift-async-algorithms icon indicating copy to clipboard operation
swift-async-algorithms copied to clipboard

for await-latest ?

Open ursusursus opened this issue 1 year ago • 16 comments

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

ursusursus avatar Aug 21 '24 02:08 ursusursus