Combine

    [Combine 책 정리] Chapter 13: Resource Management

    안녕하세요 코찐입니다. 아래의 자료를 따라서 공부하고 있습니다. https://www.raywenderlich.com/books/combine-asynchronous-programming-with-swift/v2.0 리소스 관리하는 Publisher 들인데, API 작업할 때 유용하게 사용할 수 있습니다. share value 타입이 아닌 reference 타입의 publisher를 공유할 수 있도록 해줍니다. 주의할 점은 이미 complete 된 share publisher를 구독하면 complete만 받게 됩니다. let shared = URLSession.shared .dataTaskPublisher(for: URL(string: "https://www.raywenderlich.com")!) .ma..

    [Combine 책 정리] Chapter 12: Key-Value Observing

    안녕하세요 코찐입니다. 아래의 자료를 따라서 공부하고 있습니다. https://www.raywenderlich.com/books/combine-asynchronous-programming-with-swift/v2.0 KVO 그 유명한 KVO 입니다. OperationQueue의 operation 개수가 변경되면 sink에서 이벤트를 받아볼 수 있습니다. let queue = OperationQueue() let subscription = queue.publisher(for: \.operationCount) .sink { print("Outstanding operations in queue: \($0)") } 커스텀으로 만들려면? 1. NSObject 상속 2. @objc dynamic 키워드 KVO가 O..

    [Combine 책 정리] Chapter 11: Timers

    안녕하세요 코찐입니다. 아래의 자료를 따라서 공부하고 있습니다. https://www.raywenderlich.com/books/combine-asynchronous-programming-with-swift/v2.0 타이머 클래스에는 삼형제가 있습니다. RunLoop, Timer, DispatchQueue RunLoop 특정 RunLoop 상에서 이벤트를 발생시킬 수 있습니다. 1초마다 한번씩 print 합니다. let runLoop = RunLoop.main runLoop.schedule( after: runLoop.now, interval: .seconds(1), tolerance: .milliseconds(100) ) { print("Timer fired") }.store(in: &subscript..

    [Combine 책 정리] Chapter 10: Debugging

    안녕하세요 코찐입니다. 아래의 자료를 따라서 공부하고 있습니다. https://www.raywenderlich.com/books/combine-asynchronous-programming-with-swift/v2.0 let subscription = (1...3).publisher .print("publisher") .sink { _ in } // 다음에서 발췌: By Marin Todorov. ‘Combine: Asynchronous Programming with Swift.’ Apple Books. publisher: receive subscription: (1...3) publisher: request unlimited publisher: receive value: (1) publisher: rec..

    [Combine 책 정리] Chapter 6: Time Manipulation Operators

    안녕하세요 코찐입니다. 이번 챕터는 Time manipulation(시간 조작)에 관한 챕터입니다. 아래의 자료를 따라서 공부하고 있습니다. 하나하나 따라하기 좋게 구성되어 있습니다. https://www.raywenderlich.com/books/combine-asynchronous-programming-with-swift/v2.0 https://github.com/raywenderlich/comb-materials/tree/editions/2.0/06-time-based-operators/projects raywenderlich/comb-materials The projects and the materials that accompany the Combine: Asynchronous Programmin..