Question

Say, I have this type of webflow:

def myFlow = {
    state1 {
    }
    on("next").to("stateAct")

    stateAct {
        action {
            ... DB stuff ...
        }
    }
    on("success").to("state2")

    state2 {
    }
    on("prev").to("state1")
}

Now, the contents of "stateAct" is common between state1 and state2. Meaning, if I press "next" from state1, I need to pass by stateAct before I can go to state2 (which is the current implementation) and if I press "prev" in state2, I need it to pass by stateAct before it goes to state1. Obviously, in the sample webflow above, it doesn't do the latter.

So, my question is, is there a way to detect in stateAct who called it (state1 or state2) so that I can redirect accordingly on "success"? Or something similar to that behavior?

Thanks!

-Lee

Was it helpful?

Solution

Why not store this info in a flow-scoped variable? Something like:

def myFlow = {
    state1 {
      on("next") {
          flow.originator = 'state1'
      }.to("stateAct")
    }
    stateAct {
        action {
            if (flow.originator == 'state1') do something
            if (flow.originator == 'state2') do something else
        }
    }
    on("success").to("state2")

    state2 {

      on("prev"){
        flow.originator = 'state2'
      }.to("stateAct")
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top