Passing data from one Flux 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 by passing it around to other states. For this example, let's say you have two states.
The first state is set to the action
the second state is set to call
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 of type
- Click your first state. Once the state is selected, Flux Input/Output will become State Input/Output.
- Add an output string property named
- In Mapper, map
inputto the action's input
- In Mapper still, map the action's output
- Click your second state.
- Under the State Input/Output view, create an input of type string with the name
- Going back to Mapper, map
- Finally, click on the transition arrow and in 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, Martini has template proposals you can use to map property values accessible via the content-assist menu.
To map properties using template proposals in the Flux canvas:
- 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 whose value you want to map.
- Select the property to map the previously selected property to.
You can also use content assist to map properties in the Mapper view.