Sequencing Signals

bill's Avatar

bill

16 Sep, 2011 05:26 AM

Hi all,

I have a question regarding triggering Signals from within SignalCommands. Basically launching one SignalCommand form within another. Is this considered bad practice? I ask because I'm getting "injector rule" warnings when I try to inject a mapped Signal into a SignalCommand. If so, what is the best work-around for running commands in sequence?

  1. 1 Posted by neil on 16 Sep, 2011 07:17 AM

    neil's Avatar

    you can have a look at this:
    http://alecmce.com/as3/commandflow-another-approach-to-robotlegs-as...

    or this:
    https://github.com/darscan/robotlegs-extensions-Oil

    but you shouldn't get injection errors unless you are injecting something before it has been mapped or you are injecting something into itself... have you an example?

    it is perfectly fine to dispatch a signal from a command

  2. 2 Posted by bill on 16 Sep, 2011 03:44 PM

    bill's Avatar

    Well, it goes like this:

    In my ApplicationContext I have 2 mapped Command/Signals :

    override public startup():void{
    ... signalCommandMap.mapSignalClass( ResumeStreamSignal, ResumeStreamCommand );

    signalCommandMap.mapSignalClass( StreamProgressSignal, StreamProgressCommand );
    ... }

    Then, I've data typed the payload in StreamProgressSignal:

    public function StreamProgressSignal(...valueClasses)

        {
            super( TrackVO );
        }
    

    Now, what I want to do is daisy chain the 2 commands starting with ResumeStreamCommand:

    public class ResumeStreamCommand extends SignalCommand

    {
        [Inject] public var progSig:StreamProgressSignal;
    
        ...
    
        public function ResumeStreamCommand()
        {
            super();
    
        }
    
        override public function execute():void{
            ...
                        progSig.dispatch( {track} );
        }
    }
    

    Because both commands are mapped, I'm getting injection warnings. I tried using

    commandMap(StreamProgressSignal, {track})

    but got the same warnings. Everything works, I'm just wondering if there is a better practice that doesn't produce the warnings.

  3. 3 Posted by neil on 16 Sep, 2011 04:52 PM

    neil's Avatar

    Ok, are they synch or async?

    becuase if they are are synch, you can map the commands to the same signal which will act as a macro command, firing the first, then the second command.

    be careful if you are using the release candidate Signal, as you will need to use a priority signal to maintain the order of dispatch ( otherwise they will fire in reverse order)

  4. 4 Posted by bill on 16 Sep, 2011 05:11 PM

    bill's Avatar

    In this case they are sync because there is no service involved, but I have async instances as well.

    I'm not understanding how to map multiple commands to one signal. The StreamProgressSignal is triggered in other places than just within the ResumeStreamCommand. That's why they are separated in the first place. How would I go about mapping multiple commands to one Signal?

  5. 5 Posted by neil on 16 Sep, 2011 05:23 PM

    neil's Avatar

    this should do it:

    signalCommandMap.mapSignalClass( ResumeStreamSignal, ResumeStreamCommand );

    signalCommandMap.mapSignalClass( ResumeStreamSignal, StreamProgressCommand );

    but regards daisy chaining command, thats a whole subject in its self, with lots of different strategies.

    did you check out the above utils? they are two solutions to the problem

  6. 6 Posted by bill on 19 Sep, 2011 06:01 PM

    bill's Avatar

    Ah I didn't know that you can actually map one signal to multiple commands. Thanks for that.

    I did some research last weekend and found that CommandFlow (http://alecmce.com/as3/commandflow-another-approach-to-robotlegs-as...) would work well with my sequencing issues. I also looked at Macrobot which seems more powerful, but I couldn't figure out a way to add new commands with payloads during a sequence execution.

    I think I'm good for now, thanks!

  7. bill closed this discussion on 19 Sep, 2011 06:02 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac