3. AsyncStream — Push 방식 (Continuation 기반)
·
카테고리 없음
AsyncStream은 그 보일러플레이트를 클로저 하나로 줄여주는 도구입니다.3.1 왜 AsyncStream인가2단원 마지막에 만들었던 Counter를 다시 떠올려 보면.struct CounterIterator: AsyncIteratorProtocol { /* ... */ }struct Counter: AsyncSequence { typealias Element = Int typealias AsyncIterator = CounterIterator func makeAsyncIterator() -> CounterIterator { /* ... */ }}겨우 1~10까지 세는 시퀀스 하나 만들겠다고 타입 두 개 만들고, 연관 타입 선언하고, next() 구현하고… 쓰껄. 그래서 Apple이 "..