tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/379-sequencing-signalsRobotlegs: Discussion 2018-10-18T16:35:31Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/100005282011-09-16T05:26:41Z2011-09-16T05:26:41ZSequencing Signals<div><p>Hi all,</p>
<p>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?</p></div>billtag:robotlegs.tenderapp.com,2009-10-18:Comment/100005282011-09-16T07:17:10Z2011-09-16T07:18:02ZSequencing Signals<div><p>you can have a look at this:<br>
<a href=
"http://alecmce.com/as3/commandflow-another-approach-to-robotlegs-asynchronicity">
http://alecmce.com/as3/commandflow-another-approach-to-robotlegs-as...</a></p>
<p>or this:<br>
<a href=
"https://github.com/darscan/robotlegs-extensions-Oil">https://github.com/darscan/robotlegs-extensions-Oil</a></p>
<p>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?</p>
<p>it is perfectly fine to dispatch a signal from a command</p></div>neiltag:robotlegs.tenderapp.com,2009-10-18:Comment/100005282011-09-16T15:44:58Z2011-09-16T15:44:58ZSequencing Signals<div><p>Well, it goes like this:</p>
<p>In my ApplicationContext I have 2 mapped Command/Signals :</p>
<p>override public startup():void{<br>
... signalCommandMap.mapSignalClass( ResumeStreamSignal,
ResumeStreamCommand );</p>
<p>signalCommandMap.mapSignalClass( StreamProgressSignal,
StreamProgressCommand );<br>
... }</p>
<p>Then, I've data typed the payload in StreamProgressSignal:</p>
<p>public function StreamProgressSignal(...valueClasses)</p>
<pre>
<code> {
super( TrackVO );
}</code>
</pre>
<p>Now, what I want to do is daisy chain the 2 commands starting
with ResumeStreamCommand:</p>
<p>public class ResumeStreamCommand extends SignalCommand</p>
<pre>
<code>{
[Inject] public var progSig:StreamProgressSignal;
...
public function ResumeStreamCommand()
{
super();
}
override public function execute():void{
...
progSig.dispatch( {track} );
}
}</code>
</pre>
<p>Because both commands are mapped, I'm getting injection
warnings. I tried using</p>
<p>commandMap(StreamProgressSignal, {track})</p>
<p>but got the same warnings. Everything works, I'm just wondering
if there is a better practice that doesn't produce the
warnings.</p></div>billtag:robotlegs.tenderapp.com,2009-10-18:Comment/100005282011-09-16T16:52:53Z2011-09-16T16:52:53ZSequencing Signals<div><p>Ok, are they synch or async?</p>
<p>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.</p>
<p>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)</p></div>neiltag:robotlegs.tenderapp.com,2009-10-18:Comment/100005282011-09-16T17:11:14Z2011-09-16T17:11:14ZSequencing Signals<div><p>In this case they are sync because there is no service involved,
but I have async instances as well.</p>
<p>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?</p></div>billtag:robotlegs.tenderapp.com,2009-10-18:Comment/100005282011-09-16T17:23:28Z2011-09-16T17:23:28ZSequencing Signals<div><p>this should do it:</p>
<p>signalCommandMap.mapSignalClass( ResumeStreamSignal,
ResumeStreamCommand );</p>
<p>signalCommandMap.mapSignalClass( ResumeStreamSignal,
StreamProgressCommand );</p>
<p>but regards daisy chaining command, thats a whole subject in its
self, with lots of different strategies.</p>
<p>did you check out the above utils? they are two solutions to the
problem</p></div>neiltag:robotlegs.tenderapp.com,2009-10-18:Comment/100005282011-09-19T18:01:54Z2011-09-19T18:01:54ZSequencing Signals<div><p>Ah I didn't know that you can actually map one signal to
multiple commands. Thanks for that.</p>
<p>I did some research last weekend and found that CommandFlow
(<a href=
"http://alecmce.com/as3/commandflow-another-approach-to-robotlegs-asynchronicity">http://alecmce.com/as3/commandflow-another-approach-to-robotlegs-as...</a>)
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.</p>
<p>I think I'm good for now, thanks!</p></div>bill