Announcement: Reducer Protocol Beta

Thanks to a bunch of Swift 5.7 features, we're excited to kick off another beta!

By leveraging primary associated types and new result builder machinery, the Composable Architecture should let you compose your app's logic in the same way you compose SwiftUI views.

For example, an app with 3 tabs can be assembled into a single feature in its body:

struct App: ReducerProtocol {
  struct State {
    var activity: Activity.State
    var profile: Profile.State
    var settings: Settings.State
  }

  enum Action {
    case activity(Activity.Action)
    case profile(Profile.Action)
    case settings(Settings.Action)
  }

  var body: some ReducerProtocol<State, Action> {
    Scope(state: \.activity, action: /Action.activity) {
      Activity()
    }
    Scope(state: \.profile, action: /Action.profile) {
      Profile()
    }
    Scope(state: \.settings, action: /Action.settings) {
      Settings()
    }
  }
}

Read more about it on GitHub, including how to start using it today:

7 Likes