Mike's Avatar


14 Dec, 2013 09:50 PM

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, OpenFileEvent).toCommand(OpenFileSeqCommand);

Thank you for any insight,

  1. Support Staff 1 Posted by Ondina D.F. on 15 Dec, 2013 10:40 AM

    Ondina D.F.'s Avatar

    Hello Mike,

    I've never used the directCommandMap until today. So, I've followed the instructions from the readme file:

    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:

    _context = new Context()
            .configure(ModelsConfig, ServicesConfig, ControllersConfig, MediatorsConfig)
            .configure(new ContextView(view));

    The DirectCommandMapExtension is included in the MVCSBundle, so it will be installed.

    I've built 4 commands:





    Inside of BootstrapCommand:

    public class BootstrapCommand
        public var directCommandMap:IDirectCommandMap;
        public function execute():void

    Inside of ControllersConfig (where I map all my commands) I've experimented with 2 ways of mapping the BootstrapCommand:

    • first to be triggered by an event that I would dispatch from a mediator, for example:;
    • and also to be executed right away:;

    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.

    Is the mapping created in its own class or in a config file?

    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;)


  2. 2 Posted by Mike on 17 Dec, 2013 02:36 PM

    Mike's Avatar

    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,

  3. Support Staff 3 Posted by Ondina D.F. on 22 Jan, 2014 03:22 PM

    Ondina D.F.'s Avatar

    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.

  4. Ondina D.F. closed this discussion on 22 Jan, 2014 03:22 PM.

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