Skip to content
Discussion options

You must be logged in to vote

I think we are missing the tool that makes it possible to first single out an enum field in your state, and then destructure it for running child reducers on each case.

Without resorting to optional paths (which are still experimental and only really exist in the isowords code base), there's a hacky thing you can try:

var body: some ReducerProtocol<State, Action> {
  Scope(state: \.route, action: Action.route) {
    EmptyReducer()
      .ifCaseLet(...)
      .ifCaseLet(...)
      .ifCaseLet(...)
  }
  Reduce { state, action in 
    // Parent logic
  }
}

It's not great, but it should help you move forward. We will think more about what this tool should look like.

It's also worth mentioning…

Replies: 5 comments 8 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@PorterHoskins
Comment options

@stephencelis
Comment options

@stephencelis
Comment options

@BornaMajstorovic
Comment options

Answer selected by stephencelis
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@stephencelis
Comment options

@RuiAAPeres
Comment options

@stephencelis
Comment options

@RuiAAPeres
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
7 participants