SignalCommandMap

jason.merrill's Avatar

jason.merrill

18 Feb, 2011 07:23 PM

(Moving this from an existing thread)

I am trying to use Joel Hooks' SignalCommandMap on a RL project. The Signal is being dispatched, but the command's execute function is not firing.

Here is my Context:


public class BannerContext extends SignalContext
{

public var bannerView:BannerView;

public function BannerContext(contextView:DisplayObjectContainer)
{
    super(contextView);
}

override public function startup():void
{

    bannerView = new BannerView();

    injector.mapSingleton(BannerModel);
    injector.mapSingleton(SendImagesSignal);

    signalCommandMap.mapSignalClass(RequestImagesSignal, SetDisplayImageVOsCommand);

    mediatorMap.mapView(BannerView, BannerViewMediator);

    contextView.addChild(bannerView);
}

}

The mediator that dispatches the signal looks like this:


public class BannerViewMediator extends Mediator
{
    [Inject]
    public var bannerView:BannerView;

    [Inject]
    public var sendImages:SendImagesSignal;

    public function BannerViewMediator()
    {
        super();
    }

    override public function onRegister():void
    {
        sendImages.add(onSendImagesSignal);
        bannerView.init();
    }

    private function onSendImagesSignal(displayImages:Vector.<DisplayImageVO>):void
    {
        bannerView.loadImages(displayImages);
    }
}

Stray wrote:

Silly question - but you are injecting the instance of the command that you're firing, aren't you? Wherever it gets fired from - it needs to be that instance that the command map holds.

I'm not sure I follow - doesn't this line in my mediator take care of it?

signalCommandMap.mapSignalClass(RequestImagesSignal, SetDisplayImageVOsCommand);

I can post the RequestImagesSignal class (but it's just a simple class that extends Signal) and the Command, (but it's just a standard command with an override on execute as you do).

See any problems here? Thanks so much for looking at this!

Jason Merrill

  1. Support Staff 1 Posted by Stray on 18 Feb, 2011 07:29 PM

    Stray's Avatar

    Hi Jason,

    so you've got 2 signals - SendImagesSignal and RequestImagesSignal.

    I can see that you're adding a listener to the SendImageSignal in the mediator... but where you say "The mediator that dispatches the signal looks like this:"

    There's no dispatch in there... and you're not injecting the RequestImagesSignal either - which is the one that is mapped to a Command.

    Did you mean to post some different code?

    What would really help would be to see where the RequestImagesSignal is being dispatched.

    Stray

  2. 2 Posted by jason.merrill on 18 Feb, 2011 08:15 PM

    jason.merrill's Avatar

    Ah - man, you're right - you guys are really good at making an "expert" AS3 coder like me feel pretty stupid, but you do it in such a nice way. :)

    Haha - yeah, I got my Signals mixed up. This was a mistake I should have found had I looked a little closer at my code. I refactored some things and swapped the signals and it's working great now, thanks SO much for your help. These forums are great, I'll try and not and abuse them too much. I am determined to make RL part of my workflow, so I'll be posting again, I'm sure. Thanks!

     Jason Merrill
     Instructional Technology Architect
     Bank of America Global Learning

    _______________________

    -----Original Message-----
    From: Stray [mailto:[email blocked]]
    Sent: Friday, February 18, 2011 2:30 PM
    To: Merrill, Jason
    Subject: Re: SignalCommandMap [Problems]

  3. Support Staff 3 Posted by Stray on 18 Feb, 2011 08:28 PM

    Stray's Avatar

    No problem Jason - the hard part of learning something new is always that there's so much fog that it's hard to see the things you'd normally spot right out!

    Post as much as you need, other people always benefit too - someone else is bound to make the same mistake.

    Stray

  4. Stray closed this discussion on 18 Feb, 2011 08:28 PM.

  5. jason.merrill re-opened this discussion on 18 Feb, 2011 08:36 PM

  6. 4 Posted by jason.merrill on 18 Feb, 2011 08:36 PM

    jason.merrill's Avatar

    Excellent, will do. Yeah, I have to agree with the fog comment - I've been doing my own MVC+S stuff for years, with standard custom events, some Cairngorm events and command stuff. Now a co-worker and I have jumped into Robotlegs, Signals, and Dependency Injection/Swift Suspenders, and it's a different mindset in coding. I remember seeing a presentation on DI in Flex using Parsley I think at Max back in October, and while I already know MXML and AS3 quite well, I only half-got what they meant with DI, but it makes more sense to me now. I love these framework and am determined to learn - it's very cool. Thanks for your help, I'll go ahead and close this thread.

     Jason Merrill
     Instructional Technology Architect
     Bank of America Global Learning

  7. jason.merrill closed this discussion on 18 Feb, 2011 08:36 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