v2 feature: single commands per message

Hi,

I keep improving mvcExpress! (Or in this case I should say- I keep fixing horrible v1 mistakes!)

One very important change – limitation to have one command per message added. This has several positive effects:

  • command execution is a bit faster. (5-10%)
  • If you send a message – you will have only one command to follow this message to. (less confusion.) (If you still need to execute many commands with single message, you do it from executed command.)
  • If you map command to message that is already mapped – you will get error. (more control over what is happening in your application.)
  • But if you want to just map over previous command, without unmapping it first – you can do it with help of canMapOver parameter.

If you have more then one command mapped to single message – please move them to new command that will executes them, and map it to that message.

Map function in CommandMap now looks like this:

[as3 gutter=”1″] public function map(type:String, commandClass:Class, canMapOver:Boolean = false):void {

}
[/as3]

I also improved functions to check if command, mediator, or proxy is mapped. For commands:

[as3 gutter=”1″] commandMap.isMapped("messageType");
[/as3]

this will check if any command is mapped to specific message type. You can also add command class as optional parameter to check if specific command is mapped to this type.

For proxyMap.isMapped() – you now need to pas Proxy class, not proxy object. (proxy object is now optional.)

You can find those changes in GitHub – version 2 branch.


GitHub also contains new folder : srcExtensions with mvcExpress extensions.

Currently there are 3 extensions:

  • live – for mvcExpress live functions.
  • flex – more convenient flex view object mediation.
  • unpuremvc – library to migrate pureMvc project to mvcExpress.

I am still not sure how to release and document those extensions, there will be huge amount of those(9 is currently planned). I am thinking about one general document explaining how extensions work in mvcExpress(the good and the bad). and one html document in extension root folder focusing on that extension specifics.

I am considering creating AIR tool to pack extensions you need for your project in one SWC, instead of releasing extensions as swc’s.


Speaking about tools, if you have mvcExpress 1 project and want to convert it to version 2 – you can do it with this tool:

mvcConverterExpress-v0_1_0.air

(You can also try to converting your PureMVC project into mvcExpress v2 with unpure extension, I will add similar conversion for robotLegs1 and maybe 2 in the future.)


I also fixed mvcExrpss logger to work with version 2 beta!

mvcExpress-v2.0.beta1-logger-v1_1.swc


Coming soon to version 2:

  • Module to module communication via scopes, and data sharing via scopes will be moved to extension. (this will make core of framework lighter and a bit faster(4%).)
  • More then one mediators mediating one view object support. (this is needed for mediating view interfaces.)

Have fun with flash.

6 thoughts on “v2 feature: single commands per message”

  1. Would there be a optional possibility to map multiple commands to a message? If not, do you think it would be a big problem to write an extension for it (not asking you to write one just want your ‘quick look’ opinion)

    1. Hi,

      this limitation was added to framework by design. In fact – mvcExpress v1 has possibility to map more then one command to single message. Change was done in this commit : https://github.com/MindScriptAct/mvcExpress-framework/commit/67f5e8dfdd3f9d453cedd83ff1be3dcdb8de6fc7.

      Creating extension for this feature is possible, just extend CommandMap.as to lets say CommandMapMulti.as or something, then re-implement commit changes for it. To use this CommandMap in your application – you would pass CommandMapMulti as parameter to your ModuleCore constructor.

      I think I could create this extension easily..

      But, I would like to ask why you want it? Single command per message limitation was added to keep workflow simpler, now you are SURE that every message will lead to single Command only – that makes maintaining simpler. Also it remove headache of caring what command is executed in what order.

      If you need a message to execute many commands(which is normal…) – it’s better to create dedicated command for it – that executes other commands:

      public function execute(blank:Object):{
      cammandMap.execute(FirstCommand);
      cammandMap.execute(SecondCommand);
      cammandMap.execute(ThirdCommand);
      }

      So… do you really need it? And why?

      1. I’m quite used to defining everything in one place, I don’t like adding that extra command just to call an execute on two or three other commands. Of course does give you a performance boost but in smaller projects I just see that as a burden

        1. So it is personal preference argument, it’s cool.

          Do you want to try and create this extension?

          I can look into this, but it will take same time… I have my work planned for 2 weeks at the moment.

          1. Nah it’s OK for now, I’m working on a personal project but I’m using 1.4.2 version. Was just wondering for the future.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>