ReactiveFeedback icon indicating copy to clipboard operation
ReactiveFeedback copied to clipboard

SwiftUI + RAF == ❤️

Open RuiAAPeres opened this issue 4 years ago • 1 comments

Hello good people. I downloaded the work that @andersio did here https://github.com/ReactiveCocoa/ReactiveSwift/pull/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? ❤️

RuiAAPeres avatar May 09 '20 20:05 RuiAAPeres

See https://github.com/ReactiveCocoa/Loop/issues/2 in the community fork for SwiftUI integration concepts.

ReactiveCocoa/ReactiveSwift#776 is not strictly required to implement them.

andersio avatar May 11 '20 23:05 andersio