비동기 이벤트 처리를 간단하게 처리 할 수 있는 framework
Publisher, Subscriber, Operator, Cancellable, Scheduler라는 용어가 있음
Publisher
Publisher는 n개의 subscriber에게 값 또는 에러를 전달한다.
public protocol Publisher {
associatedtype Output
associatedtype Failure : Error
func receive<S>(subscriber: S) where S : Subscriber, Self.Failure == S.Failure, Self.Output == S.Input
}
Subscriber
특정 publisher에서 데이터 스트림을 받는다.
public protocol Subscriber : CustomCombineIdentifierConvertible {
associatedtype Input
associatedtype Failure : Error
func receive(subscription: Subscription)
func receive(_ input: Self.Input) -> Subscribers.Demand
func receive(completion: Subscribers.Completion<Self.Failure>)
}
Operator
Publisher의 함수이고 리턴으로 새로운 Publisher를 만든다.
https://github.com/ra1028/SwiftUI-Combine
@Published
ObservableObject