RxSwift implementation

Hi, for the last few days, I've been trying to pull the RxSwift version of ComposableArchitecture from our internal codebase. We are trying to write some of our features using this architecture, which will be released in a few weeks. I want to bring it to the open, hoping that it can be useful to some of us here, also getting feedbacks. so that the library is more battle-tested.

The library is currently optimized for UIKit. I have no intention to support SwiftUI for now because if you're using SwiftUI, you would use Combine instead, right? :grimacing:

Some notable differences compared to the original:

  1. It uses Driver instead of Effect type so that actions from side effects will always be delivered to the main thread.
  2. Has no ViewStore. ViewStore was created for ergonomic reasons in SwiftUI and since SwiftUI is not supported, there's no reason for it to exist.
  3. To subscribe to state updates, you can use the subscribe method
class Store<State, Action> {
  public func subscribe<LocalState: Equatable>(
    _ toLocalState: @escaping (State) -> LocalState
  ) -> Driver<LocalState>
}

struct Person {
  var name: String
}

store
  .subscribe(\Person.name)
  .drive(label.rx.text)
  .disposed(by: disposeBag)

If there are enough people interested in using RxSwift version of TCA, I'll be more serious in maintaining this :slightly_smiling_face:.

6 Likes

This is great! I was thinking about making something similar when I saw the ReactiveSwift fork. Thanks for putting in the time to make this.

Pinging @freak4pc who may be interested on this :)

1 Like

Cool! In my current project I also have a trimmed downed version of TCA implemented with RxSwift, but would love to dog-food your library once it’s open-sourced.

Hey @esam091, that sounds quite exciting! I’m happy to help you bring it over to RxSwift Community on GitHub and help in any way I can. Let me know if I can help in any way.

Thanks for tagging me @LucianoPAlmeida:)

1 Like

Thanks for the support everyone.

The priority for me is to increase robustness and to shape up the API. The best way to achieve this is to have many people try this library. @freak4pc I'd love to bring this to RxSwift Community since this would reach more people :)

If the project gets a lot of traction, then an experienced maintainer would be a great help since I have never maintained an open-source project before.

For now, please give this a try and report all the issues you find. I would be happy to discuss this.

1 Like