Another Signals vs Events for Robotlegs 2

Samúel Jónasson's Avatar

Samúel Jónasson

28 Aug, 2013 05:35 PM


There are quite a few posts discussing this but not many recent, and in relation to the latest Robotlegs version. I am starting a project where I am using RL2 and "currently" Signals.

In RL1 I used to use a nice and handy signalBus that I would inject wherever I needed a signal. It seemed a bit dirty, but VERY handy and quick. It seems like I can't use that method with the latest SignalCommandMap so instead I go the cleaner way and just inject the signals where required.

Problem is - I find myself injecting signals a lot instead of injecting a signalBus once in some base mediator :)

So I started to look at how RL2 uses events for mapping and from the examples it seems less boilerplate code is required. So although Signals are super cool, it is kind of attracting to use "out of the box" methods - especially if it requires less code.

So how are you all doing it? Events? Signals? Maybe both? Anyone figured out how to make that signalBus work ? :)


  1. Support Staff 1 Posted by Ondina D.F. on 29 Aug, 2013 08:05 AM

    Ondina D.F.'s Avatar

    Hi Sammi,

    I think it is a matter of personal preference, really.

    I like Signals a lot, but I prefer Events over Signals in large projects.
    There are a few projects where I used a combination of both, which also worked fine.

    Anyone figured out how to make that signalBus work ? :)

    Do you have an example of using a "signalBus" with RL1 that you can share with us? What exactly doesn't work? Maybe you need to build a SignalBusExtension?


  2. 2 Posted by Samúel Jónasson on 29 Aug, 2013 09:51 AM

    Samúel Jónasson's Avatar

    Yes, from what I have read it seems to be of personal preference.

    What does not work out of the box is to use an instance of a signal for mapping signals. Mind you that I am no expert in Robotlegs so maybe there is a way.

    This is the API for the signalCommandMap extension. The map method expects a signal Class.

    robotlegs.bender.extensions.signalCommandMap.api.​ : Class) : ICommandMapper

    In RL1 I used to have a class called SignalBus that had signal constants like below defined.

    public const entryChanged : Signal = new Signal(EntryVO);
    public const entryRemoved : Signal = new Signal(Number);
    public const removeEntry : Signal = new Signal(Number);

    Then I would inject an instance of that class where ever I needed to use the signals.

    public var signalBus : SignalBus;

    And when mapping them to commands I did this:

    signalCommandMap.mapSignal(signalBus.entryChanged, EntryChangedCommand);

    Then when I wanted to listen for a signal I would do:


    So the signal bus was just a way to reduce boilerplate code. I did not have to create classes for the signals, just add a line to the SignalBus.

    I am sure you are right. If I wanted this "old and handy" way of doing things in smaller apps I would most likely build a SignalBusExtension. But since I haven't dug into how to do that I think I will switch over to using events. Many seem to prefer that for larger projectes.

    A quick Google gave me this project that uses the same kind of signalBus.


  3. Support Staff 3 Posted by Ondina D.F. on 29 Aug, 2013 02:12 PM

    Ondina D.F.'s Avatar

    I've tried out the SignalBus you linked to. With just a few changes SignalExecutorMap works with robotlegs 2, too.


    signal = injectorForSignalInstance.instantiate(signalClass);
    injectorForSignalInstance.mapValue(signalClass, signal);

    changed to:

    signal = injectorForSignalInstance.getInstance(signalClass);;

    and this:

    var command:Object = injector.instantiate(commandClass);


    var command:Object = injector.getOrCreateNewInstance(commandClass);

    Concerning the rl2 SignalCommandMapExtension, I suggest contacting Ken Rogers (pixels4nickels) or creynders. Open an issue/enhancement here:

    I'll add Ken and creynders to the watchers list for this thread, so they'll get notified and maybe they'll respond...


  4. 4 Posted by Samúel Jónasson on 29 Aug, 2013 02:17 PM

    Samúel Jónasson's Avatar

    Nice Ondina,

    Thank you for looking into this. Much appreciated!


  5. Ondina D.F. closed this discussion on 11 Oct, 2013 08:52 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? 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