Which signal(s) execute the command

ronaldohard's Avatar

ronaldohard

11 Jun, 2013 09:39 PM

I researched forum posts and found a similar question in this link:
http://knowledge.robotlegs.org/discussions/problems/417-know-which-...

But I have another situation.

I have a menu item with three sub items, so I made one command for these sub items, for example:

signalCommandMap.mapSignalClass (Signalises, SignalCommand);
signalCommandMap.mapSignalClass (SignalB, SignalCommand);
signalCommandMap.mapSignalClass (SignalC, SignalCommand);

In my code for the menu while not generally the case for dispatch, for example:

onClickedMenu public function (event: MenuClickEvent): void { var name: String = event.menuName; var signal: Class = MenuItem.selectByValue (name). signal; if (signal! = null) { (Injector.getInstance (signal) the Signal). Dispatch (); } }

But I wonder if you know how to run the command () which signal was triggered calls for it, I would not want to move in the menu structure, because only these items need parameter.

thanks

  1. 1 Posted by ronaldohard on 11 Jun, 2013 10:45 PM

    ronaldohard's Avatar

    Sorry,

    excuse me,

    I ended up creating 3 commands for each signal to remain unbound structure.

    Or believe to be good practice to do this that I posted above.

    Thanks to all

  2. Support Staff 2 Posted by Ondina D.F. on 12 Jun, 2013 08:09 AM

    Ondina D.F.'s Avatar

    Hey Ronaldo,

    I’m curious as to why you need 3 signals, triggering the same command. Why don’t you dispatch one signal with different values as a payload depending on the selected item?

    What is your SignalCommand supposed to do? Is there a difference between what should happen, if you selected item A, B, or C? For example, is selecting item A triggering a server request, while selecting item B is updating a model (ModelB), and selecting item C is updating another model(ModelC)? If so, then having 3 signals and 3 separate commands for each action would be my choice, too.

    If, on the contrary, selecting A, B, or C is followed by updating the same model (for example), then I’d use just one signal with a payload ( a VO wrapping the params) and one command.

    Ondina

  3. 3 Posted by ronaldohard on 12 Jun, 2013 03:44 PM

    ronaldohard's Avatar

    sorry my english,

    Exactly, could spend the same signal receiving parameter, but the form of the trigger signal is done dynamically without parameter (and would not want to mess this dynamic code).

    Not to change the code of the dispatch(), was thinking of doing 3 different signals calling the same command, and the command would make a switch () to take the decições based on the corresponding signal.

    Both signals ExtendScript call a file with three functions. So my command would execute a javascript function corresponding to the selected item.

    The central question would be is there a way to know who shot, however believe that this is not a good practice.

    I could even ask if I had many menu items, I would have to change the way shooting passing parameters, ok?

    Hard,

  4. Support Staff 4 Posted by Ondina D.F. on 13 Jun, 2013 11:33 AM

    Ondina D.F.'s Avatar

    The central question would be is there a way to know who shot, however believe that this is not a good practice.

    The command has no idea who triggered it. As far as I know, there is no way to find out which signal/event triggered the command, unless you pass that information via a payload (signal’s parameters).

    Exactly, could spend the same signal receiving parameter, but the form of the trigger signal is done dynamically without parameter (and would not want to mess this dynamic code).

    But you let the mediator of the view re-dispatch those signals, right?
    That means you add listeners for your signals inside your mediator, so it knows which signal to dispatch to trigger a command, namely the command to which the signal has been mapped.

    So, the mediator could dispatch a signal with a payload (a VO as parameter) that would be injected into a command and the payload values would be used to differentiate between the actions inside the command.

    and would not want to mess this dynamic code

    Still, I think it would be easier to pass a VO to a signal, even if it was created dynamically.

    Maybe you should take a look at the TodoList Demo, for inspiration:
    https://github.com/peterkeating/robotlegs-demo-TodoList

    See the Signals with a Todo Vo as a payload:
    https://github.com/peterkeating/robotlegs-demo-TodoList/blob/master...

    I could even ask if I had many menu items, I would have to change the way shooting passing parameters, ok?

    What do you mean? Please try explaining it again:)

  5. Support Staff 5 Posted by Ondina D.F. on 21 Jun, 2013 10:13 AM

    Ondina D.F.'s Avatar

    You can re-open this discussion, if need be.

  6. Ondina D.F. closed this discussion on 21 Jun, 2013 10:13 AM.

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