signal and signalcommand problem

seb's Avatar

seb

07 Nov, 2010 12:51 PM

Hi,

If i am passing to parameters of the same type in my signal how do I then get them trough injection in my signal command?

consider the following code.

my signal looks like this:
package
{

import org.osflash.signals.Signal;

public class MySignal extends Signal
{
    public function MySignal(...parameters)
    {
        super(String , String);
    }
}

}

and my command like this:
package
{

import org.robotlegs.mvcs.Command;
import org.robotlegs.mvcs.SignalCommand;

public class MyCommand extends SignalCommand
{

    [Inject]
    public var string1:String;

    [Inject]
    public var string2:String;

    public function MyCommand()
    {
        super();
    }

    override public function execute():void
    {
        trace(string1, string2)
    }
}

}

string1 and string2 have the same value and correspond to the value of the 1st parameter passed through my signal.

how do i get the value sent through the second parameter of my signal?

Many thanks
S

  1. Support Staff 1 Posted by creynders on 07 Nov, 2010 12:57 PM

    creynders's Avatar

    You can't. You have to make a separate value object that stores the 2 values and pass that.

  2. 2 Posted by seb on 07 Nov, 2010 05:23 PM

    seb's Avatar

    really?? ok...

  3. 3 Posted by Stray on 07 Nov, 2010 06:54 PM

    Stray's Avatar

    Same with any DI. You can't have ambiguous injections, so to inject base types you either resort to named injection or you wrap things in strong typing. In the case of the SignalCommandMap the injection is automagic, which is great, but you lose the (ugly) naming option. So strong typing is your only option.

    It can be as simple as SpecialString() or a vo that holds the properties.

    If you really wanted to and can't see the benefit in the strong typing (I like it but you so you know it's not needed) just put the values as named properties on an object or array and dispatch/inject that instead. But you lose all the benefit of type safety.

  4. 4 Posted by Sebastien Jouha... on 07 Nov, 2010 07:03 PM

    Sebastien Jouhans's Avatar

    cool thx i already modified the signal and command to take a vo.

    thx for the input.

    On 7 November 2010 18:56, Stray <
    [email blocked]<tender%[email blocked]>
    > wrote:

  5. Stray closed this discussion on 10 Feb, 2011 06:05 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