[ https://issues.apache.org/jira/browse/FLEX-34818?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
dimitri kara updated FLEX-34818: -------------------------------- 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. was: The Signature of SequenceCaller type the target of the call as IEventDispatcher: SequenceCaller(target:IEventDispatcher, method:Function, args:Array = null, argsFunction:Function = null) But if you look at the source code, you can see that the SequenceCaller only use the target to call the method on it, without adding any event listener nor using IEventDispatcher method/property on it. Target could be a non IEventDispatcher objet and everything would work. 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. The fix is simple: the type of the target parameter and _target field should be Object and not IEventDispatcher. No other modification are needed. 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 ) ); ... } Summary: FlexUnit SequenceCaller prevent function call on objet that delagate event dispatching. (was: FlexUnit SequenceCaller prevent function call on non event-dipatcher object for no reason) > FlexUnit SequenceCaller prevent function call on objet that delagate event > dispatching. > --------------------------------------------------------------------------------------- > > Key: FLEX-34818 > URL: https://issues.apache.org/jira/browse/FLEX-34818 > Project: Apache Flex > Issue Type: Improvement > Components: FlexUnit > Reporter: dimitri kara > Priority: Minor > Labels: flexunit, fluint > Original Estimate: 10m > Remaining Estimate: 10m > > 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. -- This message was sent by Atlassian JIRA (v6.3.4#6332)