Skip to content

Scoping to struct-wrapped action enums with CaseKeyPath #3391

Answered by mbrandonw
skyler-cricut asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @skyler-cricut, you essentially need to make your ProtectedContainer into a CasePathable type so that you can continue chaining deeper into these structures. It's a little strange because clearly it's a struct, not an enum, but a struct with a single field is indistinguishable from an enum with a single field, and so it is straightforward to do.

Here are the basics (I also squashed a layer of nesting because it didn't seem important, but if you do need that you can bring it back):

@Reducer
struct Feature {
  struct State {
    var childState = ChildFeature.State()
  }

  @CasePathable
  enum Action {
    case protected(ProtectedContainer)

    struct ProtectedContainer: CasePathable {

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@skyler-cricut
Comment options

Comment options

You must be logged in to vote
1 reply
@skyler-cricut
Comment options

Answer selected by skyler-cricut
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants