How can I Chain Commands in the MVCS Implementation
It is also possible to chain commands:
public class MyChainedCommand extends Command { [Inject] public var event:MyCustomEvent; [Inject] public var model:MyModel; override public function execute():void { model.updateData( event.myCustomEventPayload ) //the UPDATED_WITH_NEW_STUFF event triggers a command and is also received by //a mediator to update a View Component, but only if a response is requested if(event.responseNeeded) dispatch( new MyCustomEvent( MyCustomEvent.UPDATED_WITH_NEW_STUFF, model.getCalculatedResponse() ) ) } }
Using this approach it is possible to chain as many Commands as needed together. In the example above a conditional statement is used. If the condition is not met, the Command is not chained. This provides extreme flexibility within your Commands to perform work on your application.