struct PublishedContentView: View {
@ObservedObject private var store: Store = .init()
var body: some View {
Group {
HStack {
Button(action: {
self.store.fire1()
}, label: {
Text("Fire 1")
})
Button(action: {
self.store.fire2()
}, label: {
Text("Fire 2")
})
}
HStack {
Text(store.value1.description)
Text(store.value2.description)
}
}
}
}
fileprivate final class Store: ObservableObject {
@Published private(set) var value1: Int = 0
@Published private(set) var value2: Int = 0
func fire1() {
value1 += 1
}
func fire2() {
value2 += 1
}
}