Skip to content

Simple way to get input from a child view #1526

Answered by mbrandonw
sillygoose asked this question in Q&A
Discussion options

You must be logged in to vote

I agree with @Alex293, and don't think this requires "shared state" in the sense that the parent wants to share state with the child. The reverse, that of the child sharing state with the parent, is implicit due to the fact that parent features hold onto all of the state of the child.

The way you can handle your situation is to have an addButtonTapped action in your child feature:

struct AddVehicleFeature: ReducerProtocol {
  struct State {  }
  enum Action { 
    case addButtonTapped
    …
  }
  
}

And the AddVehicleFeature doesn't need to handle the logic for that action. It just needs to the view to send it so that the parent can see it.

Then in the parent, you can listen for that ac…

Replies: 5 comments 4 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
1 reply
@sillygoose
Comment options

Answer selected by sillygoose
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@robfeldmann
Comment options

@mbrandonw
Comment options

@sillygoose
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
5 participants