Details
-
Improvement
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
FlexUnit 4.2
Description
The Signature of SequenceCaller type the target of the call as IEventDispatcher:
SequenceCaller(target:IEventDispatcher, method:Function, args:Array = null, argsFunction:Function = null)
But the IEventDispatcher type on the parameter/field prevents us from using the SequenceCaller on objects that delegate the event dispatching, and is a real problem with Robotlegs-like architecture where Actors (models/services) are not IEventDispatcher but use a common EventDispatcher object as an event bus.
The assumption was made that you would only use Sequence on IEventDispatcher object, but you could listen on an EventDispatcher object while making call on another object that with use the first one to dispatch events.
Example of wanted behavior (with FileService not implementing IEventDispatcher):
[Test]
public function TestFileService():void
var service:IFileService=new FileService();
var dispatcher:IEventDispatcher=new EventDispatcher;
service.dispatcher=dispatcher;
var sequence:SequenceRunner = new SequenceRunner( this );
sequence.addStep(new SequenceCaller( service , lervice.loadDefaultFile));
sequence.addStep( new SequenceWaiter( dispatcher ,FileEvent.LOADED , 100 ) );
...
}
[Update]
I found a workaround. You can pass null as the target of the SequenceCaller and it will be ok.
So the correct code is:
[Test]
public function TestFileService():void
var service:IFileService=new FileService();
var dispatcher:IEventDispatcher=new EventDispatcher;
service.dispatcher=dispatcher;
var sequence:SequenceRunner = new SequenceRunner( this );
sequence.addStep(new SequenceCaller( null , lervice.loadDefaultFile));
sequence.addStep( new SequenceWaiter( dispatcher ,FileEvent.LOADED , 100 ) );
...
}
It may help other people like me if this is added to the Docs.