Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwiftUI + RAF == ❤️ #60

Open
RuiAAPeres opened this issue May 9, 2020 · 1 comment
Open

SwiftUI + RAF == ❤️ #60

RuiAAPeres opened this issue May 9, 2020 · 1 comment

Comments

@RuiAAPeres
Copy link
Contributor

RuiAAPeres commented May 9, 2020

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
Copy link
Contributor

See ReactiveCocoa/Loop#2 in the community fork for SwiftUI integration concepts.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants