Robotlegs blank Signals (with SignalCommandMap)

archont's Avatar

archont

06 Oct, 2010 01:55 PM

Hello,

I have a mediator that mediates stage resize events. It exposes two types of signals, an instant resize, useful for instantly resizing elements like overlays and centered elements, and a delayed-response resize, suitable when I want an animation to play once the user stops fiddling with his browser window size and I want to play a snazzy animation of all elements sliding into the new center place.

The end coder may choose to map a command to either of the signals, not neccesarily both. In other terms I want a Command to be optional for either signal. If the user doesn't specifically map a Command to a Signal, that Signal dispatches but nobody is listening.

However the SignalCommandMap is designed so that the particular Signal-extending class has to be registered with a command, or else the
[Inject] public var sApplicationResized:SStageResize; generates a runtime injection error. A Signal has to be mapped to a Command or else the Injector fails.

Is there a way to work around this behavior? I know Events can be dispatched without any Command mapped to them, but I would rather use Signals, if possible.

I assume that the way to make this work is either to remove the [Inject] tag from the signal and instantiate it manually (in which case how and where should I manually map it to a Command?) or keep the [Inject] tag and somehow manually instruct the injector to inject the appropriate Command optionally later, but wouldn't doing a Class/Class (Constructor) injection mapping interfere with the later of remapping that [Inject]ion to a particular Command?

Please advise.

  1. 1 Posted by archont on 06 Oct, 2010 07:15 PM

    archont's Avatar

    After browsing the forums I can see Signals are inappropriate for this kind of use. Using more than one argument of the same type fails, it creates tight dependencies and there's no way to have the kind of loose coupling between Events and Commands that's possible with Events.

    Events it is. I find that with RobotLegs signals offer nothing more than Events. The primary reason I chose Signals is because they don't force me to create pointless Event classes. Not so with robotlegs. I might as well use Events.

  2. 2 Posted by Abel de Beer on 06 Oct, 2010 10:10 PM

    Abel de Beer's Avatar

    The issue you're experiencing has to do with the way you map the Signal class. If you don't need to execute a Command in response to a Signal dispatch, you can map the Signal using injector.mapSingleton(), for example.

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