tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/42-mapsignalclass-auto-add-signal-listenerRobotlegs: Discussion 2012-02-02T11:02:56Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/9874102010-02-08T14:43:56Z2010-02-08T14:44:01ZmapSignalClass auto add Signal listener <div><p>I am having the same issue.<br>
I can't seem to figure out how to pick up arguments that were
passed to my “CustomSignal” in my
“CustomSignalHandlerCommand”.<br>
My approach was the same as Simon’s above but in my example
the “listener” is not triggered.<br>
I and am also starting to feel that either my approach is wrong, or
something has been overlooked.</p>
<p>In brief, how we pick up on the Signal values in Commands?</p>
<p>Thanks</p>
<p>George</p></div>George Mtag:robotlegs.tenderapp.com,2009-10-18:Comment/9874102010-02-08T15:10:37Z2010-02-08T15:10:37ZmapSignalClass auto add Signal listener <div><p>Possibly a dumb question but did you check out the unit tests
Joel included in his source? Dig into his code in the support
package, for the 2 and 3 property commands.</p>
<p>Those were a big help to me.</p>
<p>My understanding is based on having used this a little, and I
could be way off base, but here's what's working for me:</p>
<p>If you've got values in your signal then you can inject them in
the command and the injection mapping of those value objects is
handled by the command map. They don't even have to be custom
types, provided they're unique in the command. They get mapped,
injected and unmapped on the fly. Very neat.</p>
<p>I think a constraint is that you can't have more than one value
of the same type in your signal arguments / injected properties.
You also can't have previously mapped those types in the
injector.</p>
<p>If you did need to have more than one value of the same type,
you could use a typed array / Vector. My preference is for custom
wrapper classes.</p>
<p>Joel may know of a better way :)</p>
<p>so - if it's someSignal.dispatch(someNumber, someString)</p>
<p>then in your command you need</p>
<p>[Inject] public var someNumber:Number;</p>
<p>[Inject] public var someString:String;</p>
<p>override public function execute()<br>
{</p>
<p>// do stuff using someNumber and someString...</p>
<p>}</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/9874102010-02-08T15:21:51Z2010-02-08T15:21:53ZmapSignalClass auto add Signal listener <div><p>Stray thanks for the reply, not a dumb question at all and
damned if I looked at the unit tests [slaps forehead], gonna dig
now, cheers!</p></div>simontag:robotlegs.tenderapp.com,2009-10-18:Comment/9874102010-02-08T15:38:52Z2010-02-08T15:38:52ZmapSignalClass auto add Signal listener <div><p>No worries, it's also worth checking out the
'routeSignalToCommand' function in SignalCommandMap:</p>
<p><a href=
"http://github.com/Stray/signals-extensions-CommandSignal/blob/master/src/org/robotlegs/base/SignalCommandMap.as">
http://github.com/Stray/signals-extensions-CommandSignal/blob/maste...</a></p>
<p>basically the process seems to be:</p>
<ul>
<li>
<p>mapping the signal->command automatically creates a listener
for the signal's dispatch, which will then trigger that
routeSignalToCommand function.</p>
</li>
<li>
<p>when the signal dispatches, the SignalCommandMap:</p>
</li>
</ul>
<p>1) Iterates through the signal's dispatch arguments, creating
mappings for those types/ values<br>
2) Asks the injector to instantiate the command, fulfiling its
injections using those mappings that just got created<br>
3) Unmaps all those signal dispatch arguments<br>
4) runs the .execute() on the command<br>
5) if it's oneshot, removes the signal->command mapping.</p>
<p>It's a pretty neat piece of work. Thx Joel & RP.</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/9874102010-02-08T15:55:37Z2010-02-08T15:55:51ZmapSignalClass auto add Signal listener <div><p>Stray, thanks for pointing these out :o)</p>
<p>(it is eagerness and deadlines that makes us overlook them)</p>
<p>I have it working nicely now!</p>
<p>Indeed props go out to Mr Hooks & Mr Penner, and to you for
pointing the way</p></div>George Mtag:robotlegs.tenderapp.com,2009-10-18:Comment/9874102010-02-08T16:24:04Z2010-02-08T16:24:04ZmapSignalClass auto add Signal listener <div><p>Stray is right, the values are injected. Right now, the
injection is a little odd I think, but this is do to the
limitations on the IInjector interface (and the reason for the
discussions regarding adding a couple of methods to it).</p>
<p>I don't think the Signal will get injected either way. The
Signal triggers the command, the command doesn't trigger the
signal. Since the Signal itself doesn't hold any properties, it
wouldn't be very useful.</p>
<p>She is also correct in that the unit tests are the only
documentation available right now :> - that will change when I
can finally come up for air!</p></div>Joel Hooks