Uploaded image for project: 'Apache Flex'
  1. Apache Flex
  2. FLEX-34818

FlexUnit SequenceCaller prevent function call on objet that delagate event dispatching.

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • FlexUnit 4.2
    • FlexUnit 4.3
    • FlexUnit

    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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            korosif dimitri kara
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - 10m
                10m
                Remaining:
                Remaining Estimate - 10m
                10m
                Logged:
                Time Spent - Not Specified
                Not Specified