Skip to content
This repository has been archived by the owner on May 4, 2022. It is now read-only.

Action Sequences (Obsolete)

Adrián Rivero edited this page Mar 10, 2017 · 3 revisions

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.

Sequence Control

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;

Running in UI Thread

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:.

Sub-Sequences

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;

Firing Sequences

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))