세상을 더 편리하게
article thumbnail
[iOS / SwiftUI] Combine - CurrentValueSubject, PassthroughSubject
Swift/Apple Framework 2023. 5. 2. 17:29

저번 글에서 가볍게 Combine을 맛봤다. 이제는 실전으로 이것저것 써보자 Combine에서 쉽게 Publisher를 만드는 방법 중 하나는 CurrentValueSubject와 PassthroughSubject 이다. CurrentValueSubjcet Single Value를 감싸고 있는 Subject로써 Value 값이 변화면 Publish 한다! import Combine import SwiftUI struct CombineView: View { var vm = CombineViewModel() @State var anyCancellable = Set() @State var number = 0 var body: some View { VStack { Text("\(number)") .padding..