(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 so far

  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.

Leave a response

If you need help or want to comment on something not related to this page, please post in the forums. Thanks!

Leave this field empty