RL and Signals with Interfaces

beaubrewer's Avatar

beaubrewer

17 May, 2010 04:30 PM

I'm not sure if this is a Robotlegs SignalCommand Map issue or a Swift Suspenders issue.

I have a Signal class that uses an interface as it's payload.
public class SelectOrderSignal extends Signal { public function SelectOrderSignal() { super(IMerchantOrder); } }

I'm mapping the signal to a command in the context using the signalCommandMap:
signalCommandMap.mapSignalClass(SelectOrderSignal, SelectOrderCommand);

The command:
public class SelectOrderCommand extends Command { [ Inject] public var order:IMerchantOrder;

    [Inject]
    public var model:MerchantModel;

    override public function execute():void
    {
        model.selectedOrder = order;
    }
}

When I dispatch the signal with a class that implements the IMerchantOrder interface, it gives me an injector missing rule error. Injector is missing a rule to handle injection into target
Can I not inject interfaces using signals this way?

  1. 1 Posted by Alex on 17 May, 2010 09:52 PM

    Alex's Avatar

    Hi.

    I'm fairly new to RL and did not go further than a testapplication with signals, as I did not get it to work with modules. But from what I understand with general RL practice, you should inject the Signal rather than the Signal's content. Then access IMerchantOrder via SelectOrderSignal. (Same as with events)

    Hope it helps,

    Alex

  2. 2 Posted by beaubrewer on 17 May, 2010 10:33 PM

    beaubrewer's Avatar

    Alex,

    Thanks for the reply. You are correct with the general RL practice. Signals that should be mapped to a command are a bit of an exception I believe. All the examples inject the signals properties/payload into the command. For all other signals that are dispatched (like ones used to update mediators, etc) I do inject the signal into the class as you mention.

    Joel Hooks example on github shows this. Take a look at the controller directory with the commands. http://github.com/joelhooks/robotlegs-examples-RobotlegsSignalsCafe...

    Thanks,
    Beau N. Brewer

  3. 3 Posted by Alex on 17 May, 2010 10:46 PM

    Alex's Avatar

    Oh ok. Sorry, my bad.
    I studied that example already, but I seem to have overlooked/forgotten that detail.
    Ok, now I'm curious what's the right solution. :)

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