-
Notifications
You must be signed in to change notification settings - Fork 25
Action Sequences (Obsolete)
To execute an action after another (depending of the weather was successful the previous action), it is used Sequences of Actions.
The general form of a Sequence is:
@Action({"parameters action 1", "parameter action 2", ..., "parameter action N"})
S'N'<Action1, Action2, ..., Action'N'> actionFieldName;
Here N
represents the number of actions used... Right now DecleX supports up to 5 actions in the sequence. See that the parameters for the Action1 are passed the first in the Parameters of the Annotation, then the parameters for the Action2 an so on.
In Sequences you can end the conditionals with ??
or !?
, this will give access to a IF...ELSE structure with the condition.
-
??
This will Execute the current action if the condition is satisfied, if not, it'll execute the second action. -
!?
This will Execute the current action if the condition is satisfied, if not, it'll execute the second action. But with the difference that after executing the current action, if it's successful, the next action will be executed as well.
You can also execute java code before or after the sequence is started, or make logical tests adding action starting with the symbol "#". This can be very useful to access variable that are not available inside the sequences.
@Action({
"#;event.performOperation();",
"#event.isSuccessful()??",
"Everything is OK",
"Something were wrong"
})
S2<Toast, Toast> onShowToast;
Frequently, a network operation should be done in Background, but when showing the result of this operation, for instance in a Toast, this should be done in the UI Tread, for it is enough to precede the action parameter with ui:
.
Action sequences can be declared in another action sequence to any deep:
@Model(async = true)
Data data;
@Action({"data", "!data.exists()?? -> (ui: Error in Data, finish(); )", "finish();"})
S3<PutModel, S2<Toast, ErrorActivity>, MainActivity> sequence;
Sequences can also be fired with the fire()
method.
@Model
Data data;
@Action({"data", "finish();"})
S2<PutModel, MainActivity> sequence;
public void someMethod() {
sequence.fire();
}
Example
- [Action Sequences Example](Action Sequences Example)
See also
- [About Flow Control (Obsolete)](About Flow Control (Obsolete))
- [Action Types (Obsolete)](Action Types (Obsolete))
- [Available Actions (Obsolete)](Avaiblable Actions (Obsolete))
Sponsored by DSpot Sp. z o.o. Contact us at info@dspot.com.pl