title: SwiftUI - Button - How to pass a function request to parent
body: <p>How can I have a button perform an action which triggers a function in its 'parent' view? I'm trying to refactor my code so that components are as small as possible.</p>
  
  <p>In this case, the button performs a few tasks, but one of them is to run a function:</p>
  
  <pre><code>Button(
   action: {
    self.setViewBackToNil()
   }){
    Text("Button")
  }
  
  // which triggers a function
  func setViewBackToNil(){
   self.userData.image = nil
   self.isProcessing = false
   .... etc
  }
  </code></pre>
  
  <p>Now, if I turn the button into its own view, I can't pass self.setViewBackToNil because it's contained within the struct of the parent.</p>
  
  <p>Is there a way for a component to trigger a function within its parent?</p>