The SequenceCommand is provided as an abstract base-class that can be extended when you wish to chain commands together for a single user-gesture, or establish some simple form of decision-based workflow.

By extending SequenceCommand, you can specify the event that should be broadcast to the controller (causing another command execution without a further user-gesture) when the current command has completed execution.

For a command implementing the Responder interface, you may choose to sequence a subsequent command on successful completion of the command, in the onResult() handler, or on failure of the command in the onFault() method.

For commands that do not implement the Responder interface, you can simply chain commands by causing the sequenced command to be invoked as the last action in your command's execute() method.

Usage

In the constructor of a concrete SequenceCommand implementation, you should set nextEvent to the event that is responsible for calling your subsequent command.

Alternatively, you can override the implicit nextEvent getter, to programmatically decide at runtime which event should be broadcast next.

Invocation of the next command in the sequence is explicitly controlled by the developer, by calling the executeNextCommand() method provided in the SequenceCommand base-class. This can be called either in the body of the execute() method (for synchronous sequencing) or in the body of an onResult() or onFault() handler (for asynchronous sequencing, that can also support conditional workflow).

See also:

Constructor

@:value({ nextEvent : null })new(?nextEvent:CairngormEvent)

Constructor, with optional nextEvent.

Variables

nextEvent:CairngormEvent

The next event in the sequence.

Methods

execute(event:CairngormEvent):Void

Abstract implementation of the execute() method.

Haxe does not explicity support abstract methods and abstract classes, so this concrete implementation of the interface method must be overridden by the developer.

executeNextCommand():Void

Call to execute the next command in the sequence.

Called explicitly by the developer within a concrete SequenceCommand implementation, this method causes the event registered with nextEvent to be broadcast, for the next command in the sequence to be called without further user-gesture.