Passing data from one state to another
Of course, your Flux actions are not limited to services that just consume data, you could take that input and process
it to pass around to other states. For this example, let's say you have two states. The first state is set to the action
String StringMethods.upperCase(String), the second state is set to call
String LoggerMethods.println(String), and
there is a blank transition between them. Let us also say, that there is a single Flux input called
input that is
For your first state:
- Click on your first state. Once the state is selected, Flux Input/Output will become State Input/Output.
- Under Output, right click and select Add > Add String. Provide a name. In this case, we will be using
- In Mapper, map
inputto the action's input.
- As for the output, map the action's output to
For your second state:
- Under the State Input/Output view, create an input of type string with the name
- Going back to the Mapper, map
- Finally, click on the transition arrow and in the Mapper, map
What we've done here is send data between two states using a transition. Data becomes available via a state's inputs and outputs and the transition acts as the bridge for data between states. This way, each state is isolated. They perform their own action without having to rely on other states' implementations. Transitions act as adapters between states.
Map properties using only keyboard commands!
To make it easier for you, Coder has template proposals you can use to map property values accessible via the content-assist menu.
To map properties using template proposals in the Design tab:
- Select the state or transition by clicking on it.
- Press the key; a pop-up will show with proposals.
- Select Map property.
- If the selection is a state and its action is an invoke step, there will be an Input or Output proposal. Select either of these options, depending on whether you want to set an input property or output property. Otherwise, ignore this step.
- Select the property to map.
- Select the property to map to the previously selected property.
To map properties using template proposal whilst in the Mapper view:
- Select a property in the Mapper view.
- Press the key; a pop up will show with proposals.
- Select Map to or Map from.
- Select the property to map it to or from.