BindableObject protocol
protocol BindableObject {
associatedtype PublisherType : Publisher
where PublisherType.Failure == Never
var didChange: PublisherType { get }
}
Slide 13
Slide 13 text
BindableObject Λ࡞Δ
class Hoge : BindableObject {
let didChange = PassthroughSubject()
var value: String {
didSet { didChange.send() }
}
}
Slide 14
Slide 14 text
SwiftUI ͱͷ bind
struct HogeView : View {
@ObjectBinding var model: Hoge
var body: some View {
Text($model.value)
}
}
HogeView(model: hogeInstance)