Answering my own question with help from Nate M from Apple:
The values sequence just requests one value at a time, so if another value arrives before it has been requested, it gets dropped. This can be fixed by adding
a call to buffer - for example:
for await anyInt in subject.buffer(size: 1000, prefetch: .keepFull, whenFull: .dropOldest).values {
print(" LOOP \(anyInt)")
}
Use a sensible value for the size parameter; .max is usable as long as you're aware that this can lead to high memory usage.
The sink sequence, on the other hand, requests unlimited elements, so it calls
the closure with every value sent.
Topic:
App & System Services
SubTopic:
General
Tags: