Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use a Vector in SignalCommand #2

Open
markstar opened this issue Mar 20, 2010 · 7 comments
Open

Cannot use a Vector in SignalCommand #2

markstar opened this issue Mar 20, 2010 · 7 comments

Comments

@markstar
Copy link

This is a brilliant library, however I can't seem to be able to inject a Vector of a custom type into a SignalCommand. The Vector is the payload of the signal that the command is registered to. All other types seem to work ok; Vector is the only one I've come across so far that doesn't. I can provide code samples if you need them.

Cheers,

Mark

@joelhooks
Copy link
Owner

I will right some unit tests and see what I can do. Cheers, Joel

@joelhooks
Copy link
Owner

can you post your code for the custom Vector?

@joelhooks
Copy link
Owner

I think your best bet is to create a payload value object that wraps your vector. using base types is a bad idea in general with the SignalCommandMap payloads because of the way they are injected into the command prior to execution.

@markstar
Copy link
Author

Wow, thanks for the quick response!

That's what I've done as a workaround for now - wrapping the vector in a value object. I didn't know the payloads were injected differently, but I'll bear that in mind for the rest of the project!

I've included the code example of the signal for you to see anyway.

Thanks a lot for your help.

Mark

package signals
{
import org.osflash.signals.Signal;
import vo.Post;

public class PostsReceived extends Signal
{
    super( Vector.<Post> );
}

}

@berryware
Copy link

I also ran into this yesterday. Array works Vector. does not. It seems akward to create a VO that is just a collection of VOs. Going to switch to Array for now. Hopefully this can be fixed.

@berryware
Copy link

As Mark said, Brilliant Library!

I recently started a new project with RL, AS3 Signals, and SignalCommandMap. This framework works very well. Going to convert all our existing Cairngorm projects over next.

@thanhbv
Copy link

thanhbv commented Apr 11, 2011

using base types is a bad idea in general with the SignalCommandMap payloads because of the way they are injected into the command prior to execution.

In my project, I see many case that the payload is only a value of a base type (String, int,..).
So, should we add a param to SignalCommandMap#mapSignal as (similar to) the following:

public function mapSignal(signal:ISignal, commandClass:Class, oneShot:Boolean = false, named:String = ""):void{
    if(named != "" && signal.valueClasses.length > 1)
        throw ...
    ...
    routeSignalToCommand(signal, arguments, commandClass, oneShot, named);
    ....
}

The named param then be passed from #routeSignalToCommand to #mapSignalValues & #unmapSignalValues, and then passed to injector.mapValue & injector.unmap.
?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants