-
Combine frameworkdeveloping study 2021. 3. 19. 21:57
Combine
- 비동기 이벤트들을 이벤트 처리 operator들에 의해 handling하는 것.
- 시간에 따라 값들을 처리하는 선언적 프레임워크.
- 값들은 다양한 비동기 이벤트들을 말한다.
- combine은 publisher와 subscirber들을 선언한다. publisher는 type을 선언하는데 이는 시간에 따라 전달되는 value를 말한다. publisher는 upstream publisher들로부터 값을 받은 값들을 republish하기 위한 operator들을 가진다.
*upstream?
publisher들의 체인의 마지막에는 subscriber가 값들을 받는다.publisher들은 값들을 subscriber가 요청할 때 준다.
애플 공식문서 - Receiving and Handling Events with Combine
비동기 소스들로부터 이벤트들을 받는 것을 customize할 수 있는 내용
debounce operator
- 퍼블리셔가 이벤트를 보내기 전에 최소한의 시간을 두는 것.
q1.cancellable을 꼭 써야 하는지?
www.appsdissected.com/save-sink-assign-subscriber-anycancellable/Save that sink! A simple solution to a common Combine problem
So you’re starting to work with Combine, because Apple is finally jumping on the reactive programming bandwagon (yay!). So you build your first Combine workflow, and it looks something like this: […
www.appsdissected.com
q2.completion을 쓰고 있는데 이걸 쓰는건 좋은 방법이 아닌가.
@Published
- 뷰모델에 published변수를 만들었을 때 didset 또는 willset을 해야 값이 즉각적으로 반영됐었다.
- 왜 그러는지?
- @Published값에 변화가 있을 때 그 데이터에 rely하는 모든 뷰는 swiftui가 자동으로 body property를 re-invoke한다고 함.
- 변화한 값을 반영하기 위해 reload하는 것.
- published는 willset이 기본인 것 같다.
참고
Swift Combine, 시작하기
Combine 기본 개념 | https://developer.apple.com/documentation/Combine Apple Document 의 Combine 을 보면 다음과 같이 설명된다. ( 번역이 미숙하지만... ) Combine - 이벤트 처리 연산자들을 통해 비동기 이벤트들을 핸
brunch.co.kr
developer.apple.com/documentation/Combine
Apple Developer Documentation
developer.apple.com
developer.apple.com/documentation/combine/receiving-and-handling-events-with-combine
Apple Developer Documentation
developer.apple.com
www.hackingwithswift.com/quick-start/swiftui/what-is-the-published-property-wrapper
'developing study' 카테고리의 다른 글
Tuist 설치시 오류 - dylib not found (0) 2023.04.11 [Swift] CGRect (0) 2022.08.28 [Swift] Frame, Bounds (0) 2022.08.28 [CI/CD] Fastlane Match 적용하기 (0) 2022.08.03 [CI/CD]FastLane (0) 2022.08.01