Combine 실습 3

Woozoo·2022년 12월 20일
import Combine

let subject = PassthroughSubject<String, Never>()

// The print() operator prints you all lifecycle events
let subscription = subject.sink { value in
	print("Subscriber received value: \(value)")
}

subject.send("Hello")
subject.send("Hello again!")
subject.send("Hello for the last time!")
subject.send(completion: .finished)
subject.send("Hello ?? :(")
// .finished이후로는 안 나옴!!
// subscription 자체도 취소 가능하다
// subscription.cancel() 메소드로!!

profile
우주형

0개의 댓글