Skip to content
Discussion options

You must be logged in to vote

Hello, @jerryga
You do not need to send an action from child to parent. Child state and child action are parts of parent state and parent action by definition:

struct Parent: Reducer {
  struct State: Equatable {
    var something: String
    var child: Child.State
  }
  enum Action: Equatable {
    case someAction
    case child(Child.Action)
  }
}

And these Parent and Child are tied in the common Store. So, the child actions can be handled in the Parent reducer the same way as its own actions:

struct Parent: Reducer {
  // ...

  func reduce(into state: inout State, action: Action) -> Effect<Action> {
    switch action {
      // ...
      case .child(let childAction):
        // Here …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@jerryga
Comment options

@jerryga
Comment options

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