(This tag must be placed inside an <EventHandlers> tag or a <MessageHandlers> tag)

The CommandInvoker tag is very similar to the MethodInvoker tag, but limited. It only allows specifying the generator class to instantiate. It will always call the method "execute" and pass the current event as its only argument. This tag is very useful when reusing Cairngorm commands.

<CommandInvoker generator="CommandClassName" />

The above example would be the same as doing the following in ActionScript code:

var myCommand:CommandClassName = new CommandClassName();


CommandInvoker is only a short-cut tag, as the same can be accomplished with a MethodInvoker tag:


Note: when placed inside a MessageHandlers list, the command will receive a MessagingEvent.

4 responses

  1. In the Command design pattern, commands are supposed to die after execution (no reference kept). Does Mate cache the objects generated from CommandInvoker (like it does with MethodInvoker and others)?
  2. @ Jeff,
    You can do both, save it on the cache or create a new object every time. There is a cache attribute in the tag that allows you to do that. By default is "inherit" that means that will use the global value defined in the event map. You can set that to "none" if you want the same behavior as Cairngorm does.
  3. My current application is using Cairngorm framework and I am trying to migrate to Mate(just in one place). Here are what I did:
    1. I add the mate swc file in libs,
    2. calling dispatchEvent (replace CairngormEventDispatcher.getInstance.dispatchEvent)
    3. I define a MainEventMap.mxml and add it in main.mxml
    4. In this mainEventMap, I define a CommandInvoker inside EventHandlers tag, and specify the command class name for generator.

    The project compiled, but runtime, the dispatchEvent statement was called but the command constructor was not called. Did I miss something?
  4. Hi, Hong

    I tried to figure out how your application should look like. Then I can give you the suggestion below, according to information you posted.

    1. dispatchEvent should be invoked within any class which based on UIComponent. dispatchEvent will dispatch your event up to the top via component hierachy.

    2. Check you have define correct 'type' property for EventHandlers tag. Mate will validate your event's type with this to invoke the CommandInvoker.

Comments now closed