SwiftUI + RAF == ❤️
RuiAAPeres opened this issue · 1 comments
RuiAAPeres commented
Hello good people. I downloaded the work that @andersio did here ReactiveCocoa/ReactiveSwift#776 and added the following extension to the Store
:
@available(iOS 13.0, *)
extension Store: ObservableObject {
public var objectWillChange: ProducerPublisher<Context<State, Event>, Never> {
self.state.producer.publisher()
}
}
This seemed to be enough to power a small SwiftUI view:
struct ContentView: View {
@ObservedObject var store: Store<Counter.State, Counter.Event>
var body: some View {
VStack {
Text("\(store.state.value.count)")
Button(action: {
self.store.send(event: .increment)
}, label: {
Text("Increment")
})
}
}
}
How do you think we could move this forward? ❤️
andersio commented
See ReactiveCocoa/Loop#2 in the community fork for SwiftUI integration concepts.
ReactiveCocoa/ReactiveSwift#776 is not strictly required to implement them.