title: Grails WebFlow DRY Branching Logic
body: <p>Grails WebFlow noob here...</p>
  
  <p>One state in my WebFlow receives two events that need to trigger the same action and then transition to separate states if that action is successful.  My initial attempt repeated the code in the <code>actionState</code>.  Not good.  So, after some trial and error, I came up with the following. </p>
  
  <pre><code>    state0 {
          on("event1") {
               flash.stateAfterNext = "state1"
          }.to "actionState"
  
          on("event2") {
              flash.stateAfterNext = "state2"
          }.to "actionState"
      }
  
      actionState {
          action {
              flow.unit = Unit.get(params.unit)
              success()
          }
          on("success").to { flash.stateAfterNext }
          on(Exception).to "home"
      }
  
      state1 { ... }
  
      state2 { ... }
  </code></pre>
  
  <p>This works but is it good Grails practice?  Is there a better way to handle flow branching logic like this?  In particular, should I have used a subflow here, and, if so, what would that look like?</p>
  
  <p>Note:  I attempted to move the code in <code>actionState</code> into a separate method but since it references <code>flow</code> that didn't work.</p>