Multiple named argument via Signal Command map

katopz's Avatar

katopz

18 Jul, 2013 09:09 AM

Hi guys!

normally i use this fix http://sjhewitt.co.uk/2010/02/robotlegs-and-as3signals-injecting-interfaces-and-named-arguments/
for RL1, so is there any other fix or way/workaround like this for RL2?

Thanks

  1. Support Staff 1 Posted by Ondina D.F. on 18 Jul, 2013 01:01 PM

    Ondina D.F.'s Avatar

    Hello,

    I don't know if the new Signal command map for Robotlegs2 has a solution for your problem, but here it is, in case you haven't seen it already:

    https://github.com/robotlegs/robotlegs-extensions-SignalCommandMap

  2. Support Staff 2 Posted by creynders on 18 Jul, 2013 02:27 PM

    creynders's Avatar

    We've provided another mechanism: all payload values are optionally passed to the execute method of the command.
    All you need to do is turn off the automatic injection of payload values into the command and add method parameters corresponding to the signalValues to the execute method.

    //InjectionTestSignal
    public function InjectionTestSignal ()
    {
        super(String, String, IList, IList);
    }
    
    //InjectionTestCommand
    public function execute(s1:String, s2:String, l1:IList, l2:IList ):void{
        //do something crazy!
    }
    
    //CommandConfig
    signalCommandMap.map(InjectionTestSignal)
        .toCommand(InjectionTestCommand)
        .withPayloadInjection(false); //don't forget this one
    

    You have to set withPayloadInjection to false otherwise it will error out, since it'll try to map two different values to the same type (String and IList).

    Haven't tested it out, but it should definitely work., if not: let me know.
    TBH, we never had this use case in mind, but we did try to make everything a bit more versatile; I hope we succeeded (considering the amount of brain power we put into :) )

  3. 3 Posted by katopz on 19 Jul, 2013 05:19 AM

    katopz's Avatar

    Hi creynders

    It seem to work but i've to change from...
    -----------------------------------------------------------------------
    public class InjectionTestCommand extends Command
    -----------------------------------------------------------------------
    to
    -----------------------------------------------------------------------
    public class InjectionTestCommand
    -----------------------------------------------------------------------
    so i can freely do
    -----------------------------------------------------------------------
    public function execute(s1:String, s2:String, l1:IList, l2:IList ):void{....}
    -----------------------------------------------------------------------

    then I just realized that i didn't need to "extends Command" am i right?

    because it just working(yeah!), but i didn't know what gonna break if i didn't extend Command...

    Thanks

  4. Support Staff 4 Posted by Shaun Smith on 21 Jul, 2013 03:23 PM

    Shaun Smith's Avatar

    then I just realized that i didn't need to "extends Command" am i right?

    You don't have to extend Command it is just a convenience class. And, in this case it is not very convenient, so you don't need to use it :)

  5. Shaun Smith closed this discussion on 21 Jul, 2013 03:23 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