DirectCommandMap
Hello,
Would someone give me some insight on how to implement
DirectCommandMap? This appears to be a new extension and there
isn't a lot of information on how to implement it.
Is the mapping created in its own class or in a config file?
Does this take the place of the usual way of mapping a command
in the config or context file?
//map controller commandMap.map(OpenFileEvent.SELECT_FILE,
OpenFileEvent).toCommand(OpenFileSeqCommand);
Thank you for any insight,
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
Support Staff 1 Posted by Ondina D.F. on 15 Dec, 2013 10:40 AM
Hello Mike,
I've never used the directCommandMap until today. So, I've followed the instructions from the readme file:
https://github.com/robotlegs/robotlegs-framework/blob/master/src/ro...
As the name "direct" implies, commands are executed directly, while the execution of commands mapped using the eventCommandMap is triggered by events :)
I've created the context:
The DirectCommandMapExtension is included in the MVCSBundle, so it will be installed.
I've built 4 commands:
BootstrapCommand
LoadXMLConfigsCommand
ConfigureServicesCommand
CheckConnectivityCommand
Inside of BootstrapCommand:
Inside of ControllersConfig (where I map all my commands) I've experimented with 2 ways of mapping the BootstrapCommand:
You can choose between the 2 mappings or even have both.
The idea is, that LoadXMLConfigsCommand, ConfigureServicesCommand and CheckConnectivityCommand should be called one after the other, synchronously. They are regular commands, with an execute() method.
You map the command(s) there, where you need them to be executed. Obviously, you need to use (inject) IDirectCommandMap everywhere you expect commands to be executed right away.
In my example, BootstrapCommand can be mapped as usual, using the eventCommandMap, if you want it to be executed at a later point in time, once or several times.
Creating task sequences (chained commands) and placing them into another command, seems to me to be a better choice than injecting IDirectCommandMap into other actors like Models, Services or Mediators.
As you can see in the readme, you can pass a payload object to the execute method, and also use hooks and guards.
creynders, who introduced the DirectCommandMapExtension, can tell you more about it, or make corrections to what I've said above, if need be;)
Ondina
2 Posted by Mike on 17 Dec, 2013 02:36 PM
Ondina,
Looks good and I greatly appreciate this I haven't had a chance to work it yet with my project. My current job is sucking most of my time from my other pursuits. I will look at this over the weekend and let you know. Again it was awesome that you took the time to do this for me. All of you do great work.
Thank you kindly,
Mike
Support Staff 3 Posted by Ondina D.F. on 22 Jan, 2014 03:22 PM
Mike, I guess, this is resolved by now. I'm going to close this discussion, but you can re-open it, if need be, or create other discussions for other issues.
Ondina D.F. closed this discussion on 22 Jan, 2014 03:22 PM.