Floating Down an AsyncStream
summary
Counts increment every 1–2 seconds up to 10 and are delivered first via NotificationCenter, then via Combine’s @Published and .values, and finally as a concrete AsyncStream produced with asyncStream.makeStream and a continuation that calls continuation.yield (and must call continuation.finish() when done). The code shows compactMap/map pipelines to turn notifications or Ints into entries, demonstrates using for await consumers, and warns unclosed streams block tasks and multiple consumers split the sequence.
AI-written summary · about
chapters (10)
- 0:00Introduction to AsyncStream
- 1:51Using Notification Center
- 4:41From Blocks to Async/Await
- 6:09Async Sequences Explained
- 9:17Refactoring with CompactMap
- 11:24Replacing Combine with AsyncStream
- 13:12Creating AsyncStream with Continuation
- 14:16Task Behavior and Cleanup
- 15:41Handling Multiple Async Streams
- 17:07AsyncStream Pitfalls
related talks
34mModern SwiftUI Callbacks using AsyncStream
27mAsync/Await: Thinking beyond Combine
29mAsynchronous Programming with Combine
35mThe Multi-Threaded Asynchronous Parallel World of Swift
36mUnderstanding Combine
42mAsync Await and More in Swift
47mManaging Combine, your existing code, and async/await
57mAsynchronous streams
